执行创建堆dump命令:

jmap 29082  -dump:live,format=b,file=aaa

如果出现以下异常信息:

[xxxxx]# jmap 29082  -dump:live,format=b,file=aaa
Attaching to core -dump:live,format=b,file=aaa from executable 29082, please wait...
Error attaching to core file: cannot open binary file
sun.jvm.hotspot.debugger.DebuggerException: cannot open binary file
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native Method)
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:286)
        at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:673)
        at sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:611)
        at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:337)
        at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304)
        at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:156)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:191)
        at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
        at sun.jvm.hotspot.tools.PMap.main(PMap.java:72)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.tools.jmap.JMap.runTool(JMap.java:201)
        at sun.tools.jmap.JMap.main(JMap.java:130)

错误排查:请检查指令的参数是否使用正确。

错误原因:出现上面异常,通常为参数指令使用错误导致。

对照正确与错误的指令:

// 错误指令
jmap 29082  -dump:live,format=b,file=aaa
// 正确指令
jmap -dump:live,format=b,file=aaa 29082

注意,jmap的指令格式为:

jmap [option] <pid>

某些情况下,还会出现如下错误:

jmap -dump:live,format=b,file=aaa pid

上述错误是在copy指令时,忘记将pid替换成对应的pid编号,同样会导致上述错误。

错误的本质就是命令使用错误,请对照排查。



jmap创建堆dump异常:Error attaching to core file: cannot open binary file插图

关注公众号:程序新视界,一个让你软实力、硬技术同步提升的平台

除非注明,否则均为程序新视界原创文章,转载必须以链接形式标明本文链接

本文链接:http://www.choupangxia.com/2022/03/03/jmap-dump-exception/