打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Java heap dump error with jmap command : Premature EOF

I have encountered below exception during execution of below command

jmap -dump:format=b,file=heap_dump.bin <process_id>

output:

Dumping heap to <file_name>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)

JDK version : 1.7.0_45

VM_OPTs :

-Xms2g -Xmx4g  -XX:+UseG1GC -XX:MaxGCPauseMillis=1500 -XX:G1HeapRegionSize=2 -XX:+PrintFlagsFinal -XX:ParallelGCThreads=4 -XX:ConcGCThreads=2 

Hardware : RHEL 5.x, 4 core CPU Linux machine 6 GB RAM

As per oracle bug report database ( http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6882554), this issue has been fixed state but I am still getting jdk 1.7 version with build no:45

Can you suggest any solution other than upgrading to Jdk 1.8, which is not possible in my case due to other dependencies?

EDIT:

I have tried with below command and this command too does not work (generated partial dump file) and shows same Premature EOF.

jmap -J-d64 -dump:format=b,file=<filename> <pid>

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.

9 MB file was written for 2 GB heap, which is not usable for analysis.

Answer:

Brian's comment is helpful to resolve the issue.

If you are using G1GC algorithm in 64 bit machine:

Below command does not work ( excluding live option)

jmap -J-d64 -dump:format=b,file=<heap_dump_filename> <pid>

you have to use below option to get the heap dump

jmap -J-d64 -dump:live,format=b,file=<heap_dump_filename> <PID>

There are some suggestions to use -F option to force heap dump but as per oracle technotes:

-F Force. Use with jmap -dump or jmap -histo option if the pid does not respond. The live suboption is not supported in this mode.

Since heap dump is required with G1GC option, above option can't be used.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
JVM分析工具链(二) - jmap和jhat
查看 JVM 内存的几个工具,建议收藏!
探究JVM内存泄露
JDK的几种分析工具
通过JMX控制在full GC前后做heap dump
线上应用故障排查之二:高内存占用
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服