简单使用
cd /home/hd/hprof_file/
/home/hd/memoryAnalyzer/ParseHeapDump.sh /home/hd/hprof_file/app.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components
- org.eclipse.mat.api:suspects:表示生成内存泄露报告
- org.eclipse.mat.api:overview:表示生成概述报告
- org.eclipse.mat.api:top_components:表示生成大对象报告
自己环境的脚本如下:
[apps@HZVM017149 dump]$ cat start.sh
source /etc/profile
nohup /data/soft/mat/ParseHeapDump.sh $1 org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components &
[apps@HZVM017149 dump]$ cat /data/soft/mat/ParseHeapDump.sh
#!/bin/sh
#
# This script parses a heap dump.
#
# Usage: ParseHeapDump.sh <path/to/dump.hprof> [report]*
#
# The leak report has the id org.eclipse.mat.api:suspects
# The top component report has the id org.eclipse.mat.api:top_components
#
"$(dirname -- "$0")"/MemoryAnalyzer -consolelog -application org.eclipse.mat.api.parse "$@"
[apps@HZVM017149 dump]$ cd /data/soft/mat/
[apps@HZVM017149 mat]$ ls -l MemoryAnalyzer
-rwxr-xr-x. 1 root root 73064 Jul 25 2019 MemoryAnalyzer
[apps@HZVM017149 dump]$ ./start.sh 44052_heap.bin
解释 分析完成后会生成三个zip包
- app_Leak_Suspects.zip
- app_System_Overview.zip
- app_Top_Components.zip
查看
我们排查内存泄露问题可以主要看app_Leak_Suspects.zip 这个压缩包下的内容。