Skip to content

Instantly share code, notes, and snippets.

@logcat
Created January 10, 2017 16:33
Show Gist options
  • Save logcat/8aeca0ee81af6fb0dc10bb0d58940007 to your computer and use it in GitHub Desktop.
Save logcat/8aeca0ee81af6fb0dc10bb0d58940007 to your computer and use it in GitHub Desktop.
android dump heap with adb help
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 ~/Desktop/$1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment