18

Im attempting to analyze a memory leak that has been driving me crazy for weeks, I found out about the eclipse MAT tool that helps you to figure out what is wrong, the problem is every single tutorial I have found says that I need to convert the format of the file from dalvik to HPROF format, however not one single tutorial I can find explains how to actually do it, instead I get vague things like this

Now the file you will get does not conform to the "standard" Sun .hprof format but is written in Dalvik's own format and you need to convert it:

hprof-conv heap-dump-tm-pid.hprof 4mat.hprof

what does that actually mean? what do I click? where do I go? Im totally lost and frustrated, any help will go a long way, thanks.

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
Edmund Rojas
  • 6,376
  • 16
  • 61
  • 92

2 Answers2

34

Sounds like you need to use the hprof-conv tool that's located in [Android-SDK]\platform-tools.

To do this on Windows:

  1. Press WINKEY+R and type in cmd

  2. Type in:

    cd "C:\android-sdk\platform-tools" (or whichever directory contains your Android sdk)

  3. Assuming you have your Dalvik file on the Desktop (I'm just guessing the directory), type in:

    hprof-conv "C:\Users\Edmund\Desktop\heap-dump-tm-pid.hprof" "C:\Users\Edmund\Desktop\4mat.hprof"

  4. This will generate the standard format HPROF file that you can use called 4mat.hprof

Community
  • 1
  • 1
Oleg Vaskevich
  • 12,444
  • 6
  • 63
  • 80
  • I went there and clicked on it but it opens and immediately closes, not sure why it does that but Im unable to use it – Edmund Rojas Jan 05 '13 at 04:17
  • You need to run it from the command line with those two parameters. – Oleg Vaskevich Jan 05 '13 at 04:18
  • Ive never used the command line so far, is it the regular command line found in my windows machine or a special console in the sdk? – Edmund Rojas Jan 05 '13 at 04:19
  • I may legitimately need a walk through of what to do in this process – Edmund Rojas Jan 05 '13 at 04:22
  • It just keeps telling me "hprof-conv is not recognized as an internal or external command" when I type in the second part for some reason – Edmund Rojas Jan 05 '13 at 04:49
  • You're not in the tools directory then. [Learn how to use the command prompt.](http://www.cs.princeton.edu/courses/archive/spr05/cos126/cmd-prompt.html) – Oleg Vaskevich Jan 05 '13 at 04:53
  • Update, I went to the tools folder and looked at its properties, the directory I needed to go to was "C:\Program Files (x86)\Android\android-sdk\tools" I did this and it worked however what Im struggling with now is step 3, is there supposed to be a space or hyphen in between the two file names in quotations? – Edmund Rojas Jan 05 '13 at 05:05
  • now Im getting a "ERROR: failed reading input" this is way too hard, android needed to make an easier way to do this – Edmund Rojas Jan 05 '13 at 05:13
  • Well, I tried my best to help. That error makes it look like there is something wrong with the input file according to [the source](https://github.com/android/platform_dalvik/blob/master/tools/hprof-conv/HprofConv.c). [This post](http://stackoverflow.com/questions/3112671/android-memory-analysing-eclipse-memory-analyzer) has information on what people have tried to do, and you now know how to run the `hprof-conv` tool, so hopefully you can get it to work. – Oleg Vaskevich Jan 05 '13 at 05:53
  • Thanks for your help appreciated it greatly! – Edmund Rojas Jan 05 '13 at 21:12
3

Just to be said: You don't explicitly need to convert the .hprof file using hprof-conv. MAT does this for you automatically - as described here. In Eclipse,

  1. open the Preferences Window,
  2. navigate to Android > DDMS
  3. and change the HPROF action to "Open in Eclipse".

enter image description here

eyecatchUp
  • 10,032
  • 4
  • 55
  • 65