jmap打dump异常

背景

    用jmap打dump文件经常遇到如下异常,打不出来,哥今天告拆大家一个终极解决方法,嘘,不要告拆别人。。

Attaching to core -F from executable 421442, 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)
。。。

解决方法

   在root用户下使用su -m user  -c " command " 搞定。如下:

[root@host11]# su -m yarn -c "jmap -dump:format=b,file=ll.bin 421442"
Dumping heap to /tmp/hsperfdata_yarn/ll.bin ...
Heap dump file created

Jhat打开dump

  jhat -J-mx4g D:softDumpViewer_bkill.comll2.bin

eclipse打开dump

1)安装mat

 打开Eclipse - >help - > Eclipse Marketplace,搜mat

 点install, 同意协议后,点击Finish就开始安装MAT了

2)选中使用

 安装完成后提示重启Eclipse,重启后打开window - > open perspective,看到Memory Analysis证明安装成功,选中memory analisys - OK

3)打开dump

  File -> open heap dump,选择你准备好的dump文件

tips:

   eclips发生out of memory,在

  C:Javaeclipsejava-2018-12eclipse目录下有个 eclips.ini文件,调整

   -Xms1024m
   -Xmx5024m

  

原文地址:https://www.cnblogs.com/cwind/p/10335787.html