Logger Buffer Size in Android | Improve Performance(2022)
Logger Buffer Size in Android | Improve Performance?
As of Android 5.0, there's also way to change the buffer size via Developer options on the device. First enable Developer options in Settings. Then navigate to the newly visible Developer options entry, scroll down, and click on logger buffer size. This will display options ranging from off to 16Mb. I have found that when switching to off, logcat will still hold and report a buffer size of 64Kb. A major advantage of using Developer options is that the selection will be persisted over reboots, but the disadvantage is that you cannot set each buffer individually.
Logcat is the one tool every Android engineer uses. But have you ever been in a situation where the log files have been truncated and you have lost precious logging information? Some encountered this issue recently when browsing through a logcat dump to find an issue with our automated tests on continuous integration.
Logcat works like a circular (ring) buffer: Once all the space is used up, old data is removed as new data is added. On the emulators we were using, the default buffer size was 64 KB, which meant that our logs were being truncated pretty early on. One option of dealing with this was to monitor the log remotely and save the logs on a host machine, but this would have been time-consuming and slightly cumbersome to set up. As such, a simpler solution was used: To mitigate truncation of the log files, we increased the maximum log buffer size.
If you ever find that your log files are being truncated while developing and you need a fast way to maintain larger log files, changing the logcat buffer size is the answer. It'll take a couple of seconds to change, and most devices today have more than enough space to support larger log file sizes. Whether to change the setting via adb or the UI is dependent upon your own use case and whether you want the settings to persist or not.