- First step doesn’t change, we have to make sure /data/misc is writable:
adb shell #su #chmod 777 /data/misc
- Take note of your application process number using the Eclipse DDMS perspective or with the command ‘ps’ within the emulator/phone shell.
- Send a SIGUSR1 signal to the process with the command:
kill -10 <pid number>In 1.5, a new API has been introduced to generate a dump programmatically, the static method dumpHprofData(String fileName) of the Debug class. Example:
- In 1.5 only one dump file will be generated (with the pattern heap-dump-tm<timestamp>-pid<myPid>.hprof), so you no longer need to concatenate it with anything.
- You still need to pull it from the emulator/phone to your computer and “deandroidize” it with the hprof-conv tool. The good news is this tool is now bundled with the SDK and you don’t need to download or compile it anymore.
adb pull /data/misc/heap-dump-tm<timestamp>-pid<myPid>.hprof . hprof-conv heap-dump-tm<timestamp>-pid<myPid>.hprof myDump.hprof
- Now you can open it with your preferred memory analysis tool (ours is MAT!).
A couple of days ago we shown you how to get a memory dump of your Android application and open it in Eclipse MAT. That procedure was valid for versions up to 1.1, but it has slightly changed for the new version 1.5 (a.k.a. cupcake).