aboutsummaryrefslogtreecommitdiff
path: root/libc/malloc_debug/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'libc/malloc_debug/README.md')
-rw-r--r--libc/malloc_debug/README.md31
1 files changed, 24 insertions, 7 deletions
diff --git a/libc/malloc_debug/README.md b/libc/malloc_debug/README.md
index 662f5f897..bebc1c141 100644
--- a/libc/malloc_debug/README.md
+++ b/libc/malloc_debug/README.md
@@ -573,6 +573,9 @@ The second backtrace frame has a pc of 0xb510 and is in the map named
/system/libutils.so which starts at 0xb000. The relative pc is 0x510 and
it is in an unknown function.
+There is a tool to visualize this data,
+[native\_heapdump\_viewer.py](https://android.googlesource.com/platform/development/+/master/scripts/native_heapdump_viewer.py).
+
Examples
========
@@ -641,13 +644,6 @@ App developers should check the NDK documentation about
for the best way to use malloc debug in Android O or later on non-rooted
devices.
-**NOTE**: Android 12 introduced a bug that can cause the wrap.\<APP\> property to
-no longer work. Use the commands below so that the wrap.\<APP\> instructions will work:
-
- adb shell setprop dalvik.vm.force-java-zygote-fork-loop true
- adb shell stop
- adb shell start
-
If you do have a rooted device, you can enable malloc debug for a specific
program/application (Android O or later):
@@ -696,3 +692,24 @@ For backtraces from your app to be useful, you'll want to keep the
symbols in your app's shared libraries rather than stripping them. That
way you'll see the location of the leak directly without having to use
something like the <code>ndk-stack</code> tool.
+
+### Analyzing heap dumps
+
+To analyze the data produced by the dumpheap command, run
+[development/scripts/native\_heapdump\_viewer.py](https://android.googlesource.com/platform/development/+/master/scripts/native_heapdump_viewer.py)
+
+In order for the script to properly symbolize the stacks in the file,
+make sure the script is executed from the tree that built the image.
+
+To collect, transfer, and analyze a dump:
+
+ adb shell am dumpheap -n <PID_TO_DUMP> /data/local/tmp/heap.txt
+ adb shell pull /data/local/tmp/heap.txt .
+ python development/scripts/native_heapdump_viewer.py --symbols /some/path/to/symbols/ heap.txt > heap_info.txt
+
+At the moment, the script will look for symbols in the given directory,
+using the path the .so file would have on the device. So if your .so file
+is at `/data/app/.../lib/arm/libx.so` on the device, it will need to be at
+`/some/path/to/symbols/data/app/.../lib/arm/libx.so` locally given the
+command line above. That is: you need to mirror the directory structure
+for the app in the symbols directory.