linux安装MAT(MemoryAnalyzerTool)工具
下载
地址: https://eclipse.dev/mat/downloads.php
注意: 1.12.0 Release需要JDK11
参数配置
在配置的部分,我们主要配置的是ParseHeapDump.sh脚本中的内存参数。
在脚本的最后一行的最后面,加上如下的参数
-vmargs -Xmx30g -XX:-UseGCOverheadLimit
具体的内存的大小,要根据dump的大小来修改,设置的太小会出现OOM的情况。
分析dump文件及生成报告
接下来,我们就是要通过ParseHeapDump.sh来分析dump文件
命令如下:
ParseHeapDump.sh <path/to/dump.hprof> [report]*
示例:
./mat/ParseHeapDump.sh ./gl.hprof org.eclipse.mat.api:suspects
执行过程,如下:
[root@nccztsjb-node-27 data]# ./mat/ParseHeapDump.sh ./gl.hprof org.eclipse.mat.api:suspects
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.eclipse.osgi.internal.framework.SystemBundleActivator (file:/data/mat/plugins/org.eclipse.osgi_3.16.300.v20210525-1715.jar)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.framework.SystemBundleActivator
WARNING: System::setSecurityManager will be removed in a future release
Task: Parsing gl.hprof
[Task: Parsing /data/./gl.hprof
[
Subtask: Scanning /data/./gl.hprof
[
[INFO] Detected compressed references, because with uncompressed 64-bit references the array at 0x7216eff10 would overlap the array at 0x7216ef5e0
[.
执行完成后,会生成一个报告的文件
将这个文件,解压到本地电脑,通过浏览器就可以进行查看,比如:
参考
XFS