使用jmap命令的Java堆转储错误:过早的EOF [英] Java heap dump error with jmap command : Premature EOF

查看:688
本文介绍了使用jmap命令的Java堆转储错误:过早的EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在执行以下命令时遇到以下异常

I have encountered below exception during execution of below command

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

输出:

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版本: 1.7.0_45

VM_OPTs:

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

硬件:RHEL 5.x,4核CPU Linux机器6 GB RAM

根据oracle bug report da tabase( http://bugs.java.com/bugdatabase/view_bug.do? bug_id = 6882554 ),这个问题已经修好但我仍然得到jdk 1.7版本,内置编号为:45

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

你能建议吗?除了升级到Jdk 1.8以外的解决方案,由于其他依赖性,这在我的情况下是不可能的?

编辑:

我尝试使用以下命令,此命令也不起作用(生成的部分转储文件)并显示相同的早熟EOF。

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 文件是为 2 GB 堆编写的,不能用于分析。

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

推荐答案

Brian的评论有助于解决问题。

Brian's comment is helpful to resolve the issue.

如果您正在使用 G1GC 64位机器中的算法:

If you are using G1GC algorithm in 64 bit machine:

下面的命令不起作用(不包括实时选项)

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

你必须使用以下选项才能获得堆转储

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

有一些建议可以使用 -F 强制堆转储的选项但是按照oracle technotes

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


-F
强制。如果pid没有响应,请使用jmap -dump或jmap -histo选项。此模式不支持实时子选项。

-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.

由于G1GC选项需要堆转储,因此无法使用上述选项。

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

这篇关于使用jmap命令的Java堆转储错误:过早的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆