背景
用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:\soft\DumpViewer_bkill.com\ll2.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:\Java\eclipse\java-2018-12\eclipse目錄下有個 eclips.ini文件,調整
-Xms1024m
-Xmx5024m