title: Java heap dump error with jmap command : Premature EOF
body: <p>I have encountered below exception during execution of below command</p>
  
  <pre><code>jmap -dump:format=b,file=heap_dump.bin &lt;process_id&gt;
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>Dumping heap to &lt;file_name&gt;
  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)
  </code></pre>
  
  <p>JDK version : <em>1.7.0_45</em></p>
  
  <p>VM_OPTs :</p>
  
  <pre><code>-Xms2g -Xmx4g  -XX:+UseG1GC -XX:MaxGCPauseMillis=1500 
  -XX:G1HeapRegionSize=2 -XX:+PrintFlagsFinal -XX:ParallelGCThreads=4 -XX:ConcGCThreads=2 
  </code></pre>
  
  <p><em>Hardware : RHEL 5.x, 4 core CPU Linux machine 6 GB RAM</em></p>
  
  <p>As per oracle bug report database ( <a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6882554" rel="nofollow noreferrer">http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6882554</a>), this issue has been fixed state but I am still getting jdk 1.7 version with build no:45</p>
  
  <p><em>Can you suggest any solution other than upgrading to Jdk 1.8, which is not possible in my case due to other dependencies?</em> </p>
  
  <p><strong><em>EDIT:</em></strong></p>
  
  <p>I have tried with below command and this command too does not work (<strong>generated partial dump file</strong>) and shows same Premature EOF. </p>
  
  <pre><code>jmap -J-d64 -dump:format=b,file=&lt;filename&gt; &lt;pid&gt;
  </code></pre>
  
  <p>I have triggered the command with the user, who started the process. That user had write permissions to the directory. The file was generated but it was incomplete. </p>
  
  <p><em>9 MB</em> file was written for <em>2 GB</em> heap, which is not usable for analysis.</p>