windows上的堆内存分析工具比较多,有jhat、VM,mat等,但是Linux上的就比较少
生产上的堆比较大,有几十个G,拿到windows分析内存根本不够,那么就只能在服务器上进行分析。这次因为生产上hiveserver2的full gc不回收,堆大小有27G,所以考虑使用mat来分析。由于使用jhat一直起不来,所以就考虑使用mat stand-alone版本,下载链接如下:https://www.eclipse.org/mat/previousReleases.php
首先看看Linux的版本是什么,再决定下载什么版本
[op@NM-304-HW ~]$ uname -a
Linux NM-304-HW 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
使用Linux上下载或者本地直接下载然后上传到服务器上
wget https://www.eclipse.org/downloads/download.php?file=/mat/1.8.1/rcp/MemoryAnalyzer-1.8.1.20180910-linux.gtk.x86_64.zip
解压:
[op@NM-304-HW ]$ unzip MemoryAnalyzer-1.8.1.20180910-linux.gtk.x86_64.zip
修改MemoryAnalyzer.ini的堆内存大小,我们是27G,修改到50G。由于这个要求jdk版本是1.8版本,默认jdk是1.7版本,那么我们使用自己安装的1.8jdk,通过临时导出path
export PATH=/home/op、l/jdk1.8.0_261/bin:$PAT/
进入到mat目录执行堆分析等待结果,结果会放在堆文件存放的目录
sh ParseHeapDump.sh /tmp/6652_dumpheap.bin org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components
三个参数说明:
The org.eclipse.mat.api:suspects argument creates a ZIP file containing the leak suspect report. This argument is optional.
The org.eclipse.mat.api:overview argument creates a ZIP file containing the overview report. This argument is optional.
The org.eclipse.mat.api:top_components argument creates a ZIP file containing the top components report. This argument is optional.
如果是大的堆文件,那么很有可能内存溢出,那么在MemoryAnalyzer.ini文件增加这个参数-XX:-UseGCOverheadLimit
官方注意事项文档:http://wiki.eclipse.org/MemoryAnalyzer/FAQ