您的位置:首页 > 其它

第23课:使用MAT对Dump文件进行分析实战

2016-05-29 09:14 901 查看
 

第23课:使用MAT对Dump文件进行分析实战

/* 王家林老师授课http://weibo.com/ilovepains  每天晚上20:00YY频道现场授课频道68917580*/

 

1 导出Dump文件

2 使用MAT对Dump文件进行分析实战

 

一:下载安装mat
www.eclipse.org/mat/downloads.php

解压缩到G:\IMFBigDataSpark2016\mat

点击MemoryAnalyzer.exe即可运行

二:分析oom,我们模拟代码运行

com.dt.spark.jvm.basics 新建OOMMAT

 

OOMMAT
package com.dt.spark.jvm.basics;

public class OOMMAT {

public static void main(String[] args) {
final int size = 512 *1024 *1024 ;
byte [] array1 =new byte [size];
byte [] array2 =new byte [size];
byte [] array3 =new byte [size];
byte [] array4 =new byte [size];
byte [] array5 =new byte [size];

}

}

vm conf
-server -Xms1024m -Xmx1024m -Xmn384m -XX:+UseParallelOldGC
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=d:/heap.bin

result:

2016-05-29T09:16:25.534+0800: [GC (Allocation Failure) [PSYoungGen: 17694K->753K(344064K)] 541982K->525045K(999424K), 0.0076781 secs] [Times: user=0.03 sys=0.00, real=0.01 secs]
2016-05-29T09:16:25.541+0800: [Full GC (Ergonomics) [PSYoungGen: 753K->0K(344064K)] [ParOldGen: 524292K->525014K(655360K)] 525045K->525014K(999424K), [Metaspace: 1748K->1748K(4480K)], 0.0121461 secs] [Times: user=0.00 sys=0.02, real=0.01 secs]
2016-05-29T09:16:25.554+0800: [GC (Allocation Failure) [PSYoungGen: 0K->0K(344064K)] 525014K->525014K(999424K), 0.0049526 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2016-05-29T09:16:25.559+0800: [Full GC (Allocation Failure) [PSYoungGen: 0K->0K(344064K)] [ParOldGen: 525014K->525004K(655360K)] 525014K->525004K(999424K), [Metaspace: 1748K->1748K(4480K)], 0.0060592 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2016-05-29T09:16:25.565+0800: Total time for which application threads were stopped: 0.0313803 seconds, Stopping threads took: 0.0000611 seconds
java.lang.OutOfMemoryError: Java heap space
Dumping heap to d:/heap.bin ...
2016-05-29T09:16:36.936+0800: Total time for which application threads were stopped: 11.2751442 seconds, Stopping threads took: 0.0001066 seconds
Heap dump file created [538171422 bytes in 11.372 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.dt.spark.jvm.basics.OOMMAT.main(OOMMAT.java:8)
Heap
PSYoungGen total 344064K, used 8847K [0x39600000, 0x51600000, 0x51600000)
eden space 294912K, 3% used [0x39600000,0x39ea3ef8,0x4b600000)
from space 49152K, 0% used [0x4e600000,0x4e600000,0x51600000)
to space 49152K, 0% used [0x4b600000,0x4b600000,0x4e600000)
ParOldGen total 655360K, used 525004K [0x11600000, 0x39600000, 0x39600000)
object space 655360K, 80% used [0x11600000,0x316b31c0,0x39600000)
Metaspace used 1769K, capacity 2242K, committed 2368K, reserved 4480K


 

三:MemoryAnalyzer.exe打开d:/heap.bin文件,就可以查看各类运行情况

 

 

 

 

 操作步骤截图



 

 

 



 



 

 

 

 



 

 

 

 

 

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: