Memory debug

static const char* DEBUG_MALLOC_PROPERTY_PROGRAM = “libc.debug.malloc.program”;
bionic/libc/bionic/malloc_common.cpp

adb shell am dumpheap -n <PID_TO_DUMP> /data/local/tmp/heap.txt

adb shell stop && adb shell setprop libc.debug.malloc.program zygote && adb shell setprop libc.debug.malloc.options backtrace && adb shell start

pid=adb shell ps -A | grep -i zygote | awk '{print $2}' && adb shell am dumpheap -n $pid /data/local/tmp/heap.txt

bootanimation

adb shell stop && adb shell setprop libc.debug.malloc.program bootanimation && adb shell setprop libc.debug.malloc.options backtrace && adb shell start

pid=adb shell ps -A | grep -i bootanimation | awk '{print $2}' && adb shell am dumpheap -n $pid /data/local/tmp/heap.txt

adb shell ps -A | grep -i bootanimation | awk ‘{print $2} | xargs adb shell kill -28 bootanimation

adb shell stop && adb shell setprop libc.debug.malloc.program zygote && adb shell setprop libc.debug.malloc.options backtrace && adb shell start

DEBUG C memory

adb shell stop && adb shell setprop libc.debug.malloc.program app_process && adb shell setprop libc.debug.malloc.options backtrace=64 && adb shell start

adb shell am dumpheap -n /data/local/tmp/native_heap.txt

adb shell am dumpheap -n 2911 /data/local/tmp/native_heap.txt
adb pull /data/local/tmp/native_heap.txt

DEBUG完全行不通:
https://android.googlesource.com/platform/bionic/+/master/libc/malloc_debug/README.md