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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理