androiddebuggingprofilingandroid-traceview

Does startMethodTracing() return an error if the buffer fills?


Debug.startMethodTracing() by default uses an 8MB "buffer size". I have a number of questions about this buffer.

  1. Is an error thrown if the buffer fills to capacity, or does it just stop logging?
  2. Does the buffer remain a fixed 8MB regardless of how much or little data written to it?
  3. If I manually specify the bufferSize parameter, what are the units? Bytes? MB?
  4. I tried growing my buffer size past 20MB or so and the app exits. I need to log about 20 real-time seconds worth of computation. Is there any way to log more data than 20MB or so? I assume it's first stored in memory, otherwise there would be no problem storing it to the SD card.

Solution

  • I ran some tests and found:

    1. If the buffer fills to capacity, the following "info" level LogCat message is displayed: TRACE STOPPED (NOTE: overflowed buffer): writing X records

    2. The buffer is between 0 and 8MB depending upon how much data is written.

    3. The bufferSize parameter is specified in bytes.

    4. To increase the amount of emulated device ram, open the AVD manager and edit your virtual device. Click on the new hardware button and select Device ram size. On my machine the largest I could enter was 1GB (value 1000).