Thursday, August 6, 2009

Automatic Memory Leak Tracking on Android

Android provides a mechanism to track memory leakage.
In folder bionic/libc/bionic/malloc_leak.c is compiled into /system/lib/, it is a memory leakage tracking version of To enable the memory leakage tracking, replace the /system/lib/ with the /system/lib/
> adb shell mv /system/lib/ /system/lib/
> adb shell mv /system/lib/ /system/lib/
Before doing that, be sure to remount the system partition to 'rw'.
Use 'mv' command may have problem without, in that case use 'cp' command instead.
With the memory leak tracking, you shall see something like "MALLOC_DEBUG = 1 (leak checker)" in your logcat output.