Showing posts with label Bionic libc. Show all posts
Showing posts with label Bionic libc. Show all posts

Wednesday, March 28, 2012

memory leak tracking on android, cont

You have Android version >= 2.2.
Make sure you have libc_malloc_debug_leak.so:
  • > adb shell ls /system/lib/libc_malloc_debug_leak.so
Enable the memory leak check:
  • > adb shell setprop libc.debug.malloc 1
Restart the Android framework, make sure the memory leak check is functional:
  • > adb shell stop
  • > adb shell start
  • > adb logcat -b main -v threadtime (you see this line in the printed log: 03-29 03:10:52.942 4200 4200 I libc : /system/bin/logcat using MALLOC_DEBUG = 1 (leak checker))
In your DDMS configuration file (e.g. ~/.android/ddms.cfg on Linux), add "native=true". This enables the Native Heap tab. Now you can use the "Native Heap" tab features to grab snapshots of the heap memory usage. Group by library to view the memory usage in libraries. Show new allocations comparing to the previous snapshot to monitor the memory allocation increments. If you are using the images built by your own, fill the "Symbol Search Path" to get more details information.

More options:
  • > adb shell setprop libc.debug.malloc 5
# For filling allocated /freed memory with patterns defined by CHK_SENTINEL_VALUE, and CHK_FILL_FREE macros.
  • > adb shell setprop libc.debug.malloc 10
# For adding pre-, and post- allocation stubs in order to detect buffer overruns.

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/libc_debug.so, it is a memory leakage tracking version of libc.so. To enable the memory leakage tracking, replace the /system/lib/libc.so with the /system/lib/libc_debug.so.
> adb shell mv /system/lib/libc.so /system/lib/libc_original.so
> adb shell mv /system/lib/libc_debug.so /system/lib/libc.so
Before doing that, be sure to remount the system partition to 'rw'.
Use 'mv' command may have problem without libc.so, 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.

Tuesday, May 19, 2009

fdatasync not found in bionic libc

fdatasync(int) declare is found in bionic/libc/include/unistd.h, but it is not actually implemented in libc. I can NOT find the fdatasync symbol in /system/lib/libc.so.

Wednesday, December 3, 2008

struct ipv6_mreq has no member named ipv6mr_interface

When I am porting ffmpeg to Google Android, I got an error: 'struct ipv6_mreq' has no member named 'ipv6mr_interface'. I dont understand what happened. When I google the related information, I got this article: Linux kernel headers violate RFC2553. The corresponding header file is bionic/libc/kernel/common/linux/in6.h. I have to correct the usage of ipv6_mreq.ipv6mr_interface into ipv6_mreq.ipv6mr_ifindex.
What I am concern is does Bionic libc use the ipv6_mreq structure in a correct way?