当我尝试用内存分析器打开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-conv
的hprof-conv
工具。
例如:
hprof-conv android.hprof mat.hprof
然后在内存分析器中打开mat.hprof。
EDIT:hprof-conv可能位于某些捆绑包中的AndroidSDK/platform-tools/
下。
如果您正在使用Eclipse,只需更改以下内容:
- 打开首选项(从"窗口"菜单)
- 导航到Android->DDMS
- 将HPROF操作更改为"在Eclipse中打开"
hprof-conv
刀具位置已更改。
它现在位于AndroidSDK/platform-tools/hprof-conv