Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a heap dump in android to eclipse format

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.

like image 352
Edmund Rojas Avatar asked Jan 05 '13 04:01

Edmund Rojas


People also ask

How do I open a heap dump File?

To open the heapdump, go to File > Open Heap Dump (Not Acquire Heap Dump) and browse to your heapdump location.

How do you analyze a heap dump?

By far the most useful and efficient analysis tool is the Eclipse Memory Analyzer. After downloading and installing it on your desktop, access the tool by choosing Open Heap Dump under the File Menu option. Once opened, the analyzing tool will then access a number of default reports open parsing the heap dump.

What is Java heap dump?

A heap dump is a snapshot of all the objects in the Java Virtual Machine (JVM) heap at a certain point in time. The JVM software allocates memory for objects from the heap for all class instances and arrays.

How do I view a heap dump File in Linux?

In Linux, to identify the process id, use ps –ef | grep java . Open the heap dump in Eclipse Memory Analyzer using the option File --> Open Heap Dump. First, it will prompt you to create a leak suspect report. The user can create it or skip it.


2 Answers

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

like image 188
Oleg Vaskevich Avatar answered Oct 29 '22 04:10

Oleg Vaskevich


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

like image 45
eyecatchUp Avatar answered Oct 29 '22 02:10

eyecatchUp