java dump分析工具再体验

  |   0 评论   |   0 浏览

背景

回忆一下java下的dump的分析方式。

再体验

文件生成

jmap -dump:live,format=b,file=heap.bin 351
Dumping heap to /home/service/var/tmp/heap.bin ...
Heap dump file created

MAT linux版本分析

下载MAT的linux版本

1.14.0需要JDK17。

wget https://mirrors.nju.edu.cn/eclipse/mat/1.14.0/rcp/MemoryAnalyzer-1.14.0.20230315-linux.gtk.x86_64.zip

如果是JDK1.8,可以下载 Memory Analyzer 1.10.0,在这里

分析

./ParseHeapDump.sh heap.bin org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

jhat分析

jhat -port <port> <file>

结果

jhat -port 9999 heap.bin
Reading from heap.bin...
Dump file created Sat Oct 07 18:35:33 CST 2023
Snapshot read, resolving...
Resolving 4622150 objects...
Chasing references, expect 924 dots............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Eliminating duplicate references............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Snapshot resolved.
Started HTTP server on port 9999
Server is ready.

FAQ

OOM怎么办

在 MemoryAnalyzer.ini中,增加或编辑以下值

-vmargs
-Xmx10g
-XX:-UseGCOverheadLimit

参考

  1. linux使用MAT分析dump文件