BioWallet Blog

BioWallet. You are the key.

Analyze an Android 1.5 memory dump

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).
  1. First step doesn’t change, we have to make sure /data/misc is writable:
    adb shell
    #chmod 777 /data/misc
  2. Take note of your application process number using the Eclipse DDMS perspective or with the command ‘ps’ within the emulator/phone shell.

  3. 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:
  4. 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.
  5. 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
  6. Now you can open it with your preferred memory analysis tool (ours is MAT!).


Anonymous said...

Thanks for the informative post!

I knocked up a quick and very dirty Perl script to automate the above with not nearly enough error checking, which can be found over here:

Post a Comment