打开HPROF文件时出错:IO异常:未知HPROF版本



当我尝试用内存分析器打开HPROF文件(由Debug.dumpHprofData创建)时,出现以下异常:

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)

如何解决此问题?

您从Android获得的hprof文件具有特定于Android的格式。您应该将Android操作系统中的hprof文件转换为标准的hprof格式。为此,您可以使用位于AndroidSDK/tools/hprof-convhprof-conv工具。

例如:

hprof-conv android.hprof mat.hprof

然后在内存分析器中打开mat.hprof。

EDIT:hprof-conv可能位于某些捆绑包中的AndroidSDK/platform-tools/下。

如果您正在使用Eclipse,只需更改以下内容:

  1. 打开首选项(从"窗口"菜单)
  2. 导航到Android->DDMS
  3. 将HPROF操作更改为"在Eclipse中打开"

hprof-conv刀具位置已更改。

它现在位于AndroidSDK/platform-tools/hprof-conv

最新更新