1

This seems to be a question asked many times. I'm using Eclipse to write an Android app, in OS X. So far, no problem, except the app crashes sometimes, and I want to see whats going on so I can fix the problem. (Its probably related to bitmaps or variables not recycling correctly. But I don't know where else to start to look into it.)

I used the DDMS tool (in eclipse) to create a dump file. Then I downloaded the MemoryAnalyzer application to open it. Here is where I have been stuck for an hour: I have to convert the file first because Eclipse writes the hprof file in a different format. How do I convert it?

The answers to this question, error openning HPROF file, directly address my question. The top answer is the same as the reference for the hprof-conv tool.

The hprof file you get from Android has android specific format. You should convert hprof >file take from Android OS into standard hprof format. For this you can use hprof-conv tool >that is located at AndrodiSDK/tools/hprof-conv.

For example:

hprof-conv android.hprof mat.hprof

And then open mat.hprof in Memory Analyzer.

I have a couple problems with this.

  1. when I open the hprof-conv tool, it shows a handful of lines about it then says "[Process completed]". And there is no place to enter any text. The only relevant info on the screen is this:

    Usage: hprof-conf infile outfile

  2. I'm in Terminal, so I open "new command..." or tried using the shell thats also open. Then when I run "hprof-conv dump1.hprof dump1a.hprof" I get the error "command not found". So I think I'm off track. I also tried "hprof-conf", instead of "hprof-conv", the way it suggests in point 1. Same error. Also tried various paths to the file, no change.

  3. if I was on the right track, how do I correctly point this command to the file location? I have it on my desktop, and its named dump1.hprof. I'm not very experienced with Terminal.

Thanks in advance for an answer, or perhaps another suggestion on how to hunt down a memory leak.

Community
  • 1
  • 1
  • Sounds like you just need to specify the full path to the command - `/full-path/hprof-conv dump1.hprof dump1a.hprof` – greg-449 Oct 15 '13 at 08:28

2 Answers2

4

If you are on mac add a ./ before the command :

./hprof-conv infile.hprof outfile.hprof
yehyatt
  • 2,295
  • 3
  • 28
  • 31
2

Hello and sorry for a late response. I just went through exactly this problem and wrote some instructions here: http://spragucm.wordpress.com/2013/11/21/debugging-android-project-ddms-heap-dump-in-eclipse/

Method 1: Use the Standalone MAT

  • go into c:...\sdk-tools\tools and copy hprof-conv.exe
  • go to whatever folder you saved your dump1.hprof file and paste the .exe file
  • open a terminal and change directory to the folder with your dump and .exe file (e.g. if folder is c:\Users\YourName\DumpFolder then type cd c:\Users\YourName\DumpFolder)
  • When you're in the folder type the following in the command prompt and hit enter: hprof-conf infile.hprof outfile.hprof

NOTE: If you get an error about directory not found, you're not in the correct directory in the command prompt

  • The outfile.hprof file should be in the same folder as the other files.

Method 2: Using MAT in Eclipse

  • Install the plug-in for MAT in Eclipse
  • Select to get heap dump as before
  • Go to Window->Open Perspective->other->Memory Analysis
  • Look through your tabs for a window with a blue disk icon in top left and expand the tab (this will have some crazy name on it with a very long string of numbers)
  • Done...you are looking at the heap dump in Eclipse
EverythingRightPlace
  • 1,197
  • 12
  • 33
Chris Sprague
  • 3,158
  • 33
  • 24