Does Android DDMS provide APIs ? I need to automate the snapshot mechanism for the native heap. Or is there any post processing tool for analysis DDMS native heap snapshots.
I wrote small script, maybe you would find it useful
heap_dump_location='/data/local/tmp/tmp.hprof'
dump_heap() {
adb shell rm $heap_dump_location
pid=`adb shell ps | grep 'com.example.packagename' | grep -v 'packagename\.' | cut -c10-15`
adb shell am dumpheap $pid $heap_dump_location
echo "Heap dump started, we have no idea when it's done, so take a look at logs, and when is done use pull_heap_dump"
}
pull_heap_dump() {
adb pull $heap_dump_location $1
}
https://gist.github.com/logcat/8aeca0ee81af6fb0dc10bb0d58940007