125

I am getting the following exception when trying to open HPROF file (created by Debug.dumpHprofData) with Memory Analyzer:

java.io.IOException: Unknown HPROF Version (JAVA PROFILE 1.0.3)
at org.eclipse.mat.hprof.AbstractParser.readVersion(AbstractParser.java:124)
at org.eclipse.mat.hprof.Pass1Parser.read(Pass1Parser.java:69)
at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:65)
at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:203)
at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:114)
at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:143)
at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:123)
at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:56)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

How do I resolve this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Asahi
  • 13,378
  • 12
  • 67
  • 87
  • under windows system you might find this post helpful http://stackoverflow.com/questions/14168485/how-to-convert-a-heap-dump-in-android-to-eclipse-format – sivi Mar 04 '14 at 17:23

3 Answers3

308

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 AndroidSDK/tools/hprof-conv.

For example:

hprof-conv android.hprof mat.hprof

And then open mat.hprof in Memory Analyzer.

EDIT: hprof-conv might be located under AndroidSDK/platform-tools/ in some bundles.

Sipty
  • 1,159
  • 1
  • 10
  • 18
inazaruk
  • 74,247
  • 24
  • 188
  • 156
  • 6
    @inazaruk hprof-conv used to run automatically when clicking the dump button, I'm not sure which version of ADT this stopped working but its likely a bug – smith324 Jan 10 '12 at 05:15
  • 1
    @smith234, It might be true for the button in DDMS. But when `Debug.dumpHprofData()` is used the conversion should be done manually. – inazaruk Jan 27 '12 at 10:02
  • I was getting a 'permission denied' error in the tools directory nevertheless. I had to chmod permissions in that directory in order for it to work. – IgorGanapolsky Feb 23 '12 at 23:56
  • Typo: the latest version of MAT requires that the filename extension is hprof, not hpof as in the example above. – greg7gkb Apr 16 '12 at 23:03
  • I get "ERROR: failed reading input" when trying to convert. Any idea? I use Android Debug Monitor 21.1.0 to produce the heap dump – Kev Oct 10 '13 at 09:02
  • 11
    just a heads up, my hprof-conv was under sdk\platform-tools instead in case anyone missed it under sdk/tools – cjayem13 Aug 27 '14 at 01:21
  • I followed every step, on ubuntu but still am getting error "hprof-conv command not found" can anybody help http://stackoverflow.com/q/29489190/1994950 – Kushal Apr 07 '15 at 10:21
41

If you are using Eclipse, just change the following:

  1. Open Preferences (from the Window menu)
  2. Navigate to Android->DDMS
  3. Change the HPROF action to "Open in Eclipse"
sparrowt
  • 2,641
  • 25
  • 24
Apirak Lunla
  • 647
  • 7
  • 5
  • In Windows 7 64bit, I couldn't convert using `hprof-conv` tool, it just didn't nothing. So tried your method and it works! I just should have to install MAT to eclipse and it now works perfectly. thanks – Paulius Vindzigelskis Jun 20 '12 at 12:43
  • 3
    It might be good to update to explain that the user should open Eclipse preferences first and then select Android from the left hand menu etc – Mick Jun 27 '12 at 22:00
  • 1
    in Luna I needed to install MAT manually: Help-> Install New Software: http://download.eclipse.org/mat/1.4/update-site/ – joecks Aug 06 '14 at 13:07
  • In my Eclipse Mars.2 (4.5.2) (Win 10) "Open in Eclipse" is already set and MAT is installed, yet I still get the "unknown HPROF version" error. I had to convert the file with "hprof-conv". – Neph Sep 05 '18 at 12:02
7

hprof-conv tool location got changed.

It is now located at AndroidSDK/platform-tools/hprof-conv

Sumoanand
  • 8,835
  • 2
  • 47
  • 46