Skip to content

Instantly share code, notes, and snippets.

@menny
Last active December 12, 2015 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menny/4689035 to your computer and use it in GitHub Desktop.
Save menny/4689035 to your computer and use it in GitHub Desktop.
Android Memory Leaks OR The Different Ways to Leak
File extFolder = Environment.getExternalStorageDirectory();
File target = new File(extFolder, "ask_mem_dump.hprof");
Debug.dumpHprofData(target.getAbsolutePath());
@menny
Copy link
Author

menny commented Feb 1, 2013

This is a very simple code snippet for how to dump an Android process (current) memory into an hprof file. I write the dump file to the SDCARD, so remember to add external storage write permission.
The output is a Dalvik HPROF file! To work with standard J2ME tools (like Eclipse Memory Analyzer) you should first convert the file:
hprof-conv ask_mem_dump.hprof converted.hprof
The 'hprof-conv' tool is part of the Android SDK package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment