Performing a java heap dump is not that hard, but many don't know about it. This makes it a good candidate for inclusion in apk_operations.py. :)
To start heap dump: "adb shell am dumpheap org.chromium.chrome:privileged_process0 /data/local/tmp/TEMP.dump"
To wait for it to finish: check logcat for "heap dump completed"
To get stacks for allocation, can also add --track-allocation to the adb command within "launch".
* The default stack size is 16. May want to increase this via: setprop debug.allocTracker.stackDepth 50
Once the snapshot is pulled to local, would be good to split out a command that can be used to view it.
E.g. probably with either:
https://android.googlesource.com/platform/art/+/master/tools/ahat/README.txt (prebuilt .jar available at go/ahat)
Or print a link to:
https://developer.android.com/studio/profile/memory-profiler#import-hprof
Comment 1 by tedc...@chromium.org
, Jan 9