EOF error when I try and take a heap dump

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux

Issue

  • We are trying to analize a memory leak in our application but we we run the jmap command to get the heap dump we get the following error:
  • /soft/jdk/jdk1.7.0_51/bin/jmap -dump:format=b,file=heapdump.hprof
Dumping heap to heapdump.hprof ...
Exception in thread "main" java.io.IOException: Premature EOF
    at sun.tools.attach.HotSpotVirtualMachine.readInt(HotSpotVirtualMachine.java:248)
    at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:199)
    at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:217)
    at sun.tools.attach.HotSpotVirtualMachine.dumpHeap(HotSpotVirtualMachine.java:180)
    at sun.tools.jmap.JMap.dump(JMap.java:242)
    at sun.tools.jmap.JMap.main(JMap.java:140)

Root Cause

It appears that this problem is a bug in the Oracle JDK's jmap binary when trying to take heap dumps from JVM's using the G1 collector. We are unable to reproduce using OpenJDK on my system (version 1.7.0_60). Are you able to migrate to OpenJDK and see if you can reproduce the issue? Can you try using a different collector other than G1? If not, you will need to reach out to Oracle for assistance in troubleshooting this issue with jmap from their JDK.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments