2011-06-02 63 views
109

我正在試圖打開HPROF文件(Debug.dumpHprofData創建)與內存分析器時以下異常:錯誤開擴HPROF文件

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) 

我該如何解決這個問題?

感謝

+0

在Windows系統下,你可能會發現這篇文章有幫助 http://stackoverflow.com/questions/14168485/how-to-convert-a-heap-dump- in-android-to-eclipse-format – sivi 2014-03-04 17:23:57

回答

280

hprof文件從你的Android得有Android的特定格式。您應該將hprof文件從Android OS轉換爲標準hprof格式。爲此,您可以使用位於AndroidSDK/tools/hprof-convhprof-conv工具。

例如:

hprof-conv android.hprof mat.hprof 

然後在內存分析器開放mat.hprof。

編輯:hprof-conv可能位於AndroidSDK/platform-tools/的某些包中。

+0

直截了當......非常感謝! – Asahi 2011-06-02 19:07:23

+6

@inazaruk hprof-conv用於點擊轉儲按鈕時自動運行,我不確定哪個版本的ADT停止工作,但它可能是一個錯誤 – smith324 2012-01-10 05:15:39

+1

@ smith234,對於DDMS中的按鈕可能是正確的。但是當使用'Debug.dumpHprofData()'時,轉換應該手動完成。 – inazaruk 2012-01-27 10:02:52

41

如果您使用的是Eclipse,只是改變了以下內容:

  1. 打開首選項(從窗口菜單)
  2. 導航到Android-> DDMS
  3. 更改HPROF行動「在Eclipse中打開「
+0

Apirak!你是男人! thx – Karoly 2012-02-29 10:01:22

+1

這比手動轉換文件更好。 – 2012-05-14 20:58:21

+0

在Windows 7 64bit中,我無法使用'hprof-conv'工具進行轉換,它只是沒有任何東西。所以試過你的方法,它的工作原理!我只需要安裝MAT來進行蝕刻,現在它可以完美工作。感謝 – 2012-06-20 12:43:17

4

hprof-conv工具位置發生了變化。

它現在位於AndroidSDK/platform-tools/hprof-conv