内容:
1.导出内存中的Dump文件
2.使用MAT对Dump文件进行分析实战
一、导出内存中的Dump文件
2.解压到合适的目录下,我自己是放到了/home/hadoop/下
3.在Eclipse IDE下编写一个程序
package DT.JavaJVM;
/**
* Hello world!
*
*/
public class OMMMat
{
public static void main( String[] args )
{
final int size = 512 * 1024 *1024;
byte[] arr1 = new byte[size];
byte[] arr2 = new byte[size];
byte[] arr3 = new byte[size];
byte[] arr4 = new byte[size];
byte[] arr5 = new byte[size];
byte[] arr6 = new byte[size];
}
}
4.配置VM的参数
-server -Xms1024m -Xmx1024m -Xmn384m -XX:+UseParallelOldGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/hadoop/mat/heap.bin
这里将输出的信息保存到/home/hadoop/mat/heap.bin
5.运行程序
二、使用MAT对Dump文件进行分析实战
1.启动Mat程序
2.加载刚才输出的heap.bin文件
3.查看分析信息