How to convert a heap dump in android to eclipse format
Asked Answered
S

2

19

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.

Sodom answered 5/1, 2013 at 4:9 Comment(0)
Z
35

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

Zurheide answered 5/1, 2013 at 4:16 Comment(10)
I went there and clicked on it but it opens and immediately closes, not sure why it does that but Im unable to use itSodom
You need to run it from the command line with those two parameters.Zurheide
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?Sodom
I may legitimately need a walk through of what to do in this processSodom
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 reasonSodom
You're not in the tools directory then. Learn how to use the command prompt.Zurheide
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?Sodom
now Im getting a "ERROR: failed reading input" this is way too hard, android needed to make an easier way to do thisSodom
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. This post 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.Zurheide
Thanks for your help appreciated it greatly!Sodom
U
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

Understudy answered 4/9, 2014 at 19:2 Comment(2)
Too bad it doesn't work for Android hprof.. but it was worth a shot :)Mae
cheers. I was ading the .hprof to the end of each file name on the cmd and it wasnt outputing the file.Beaudoin

© 2022 - 2024 — McMap. All rights reserved.