3

My jmap command is sudo -u flume /usr/java/jdk1.8.0_60/bin/jmap -F -dump:format=b,file=heap.hprof pid, But eclips mat can't open the dump file,and throw an exception.

java.lang.NullPointerException
    at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587)
    at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205)
    at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159)
    at org.eclipse.mat.hprof.Pass2Parser.read(Pass2Parser.java:89)
    at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:94)
    at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:222)
    at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:126)
    at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:145)
    at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:83)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Here is my environment.

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Linux version 2.6.32-504.el6.x86_64

But jhat can analyze it correctly.

Dev Zhou
  • 865
  • 2
  • 14
  • 21

1 Answers1

1

It appears that this is a known issue for Java 8. See Bug 471757 and Bug 476262. Neither have fixes. As a temporary workaround, I would try Yourkit. It costs money, but it's worked well for me in the past, and at least you can get a free 2 week evaluation key that should be long enough to resolve your current issue.

entpnerd
  • 10,049
  • 8
  • 47
  • 68
  • Thanks,i used Yourkit just now.But It throwed an exception `com.yourkit.util.i: com.yourkit.d.a6: C:\Users\user\Desktop\jmap\heap.hprof is not a valid snapshot file Technical detail: Snapshot file contains incorrect records and cannot be opened. Perhaps it was created by Java 5 or older.` – Dev Zhou Jan 12 '16 at 05:49
  • The fact that neither Yourkit nor MAT can read it leads me to conjecture that there is an error in heap dump file. – entpnerd Jan 12 '16 at 06:26
  • Dev Zhou, are you confident that the `jmap` command you are using is in the same JDK directory as the `java` command that is running your process corresponding to ``? Also, another dump question: Are you sure the process ID you are taking the heap dump of is correct? It must be the process corresponding to the one being run using the `java` command. Lastly, I have never had to use the `-F` myself when taking heap dumps before. Are there any good reasons your app wouldn't respond? If applicable, have you taken the server out of rotation so that it is no longer taking traffic? – entpnerd Jan 12 '16 at 06:32