专业的网站建设与优化,综合类门户网站有哪些,如何找推广平台,制作企业网站的实训报告1. 问题描述 使用Eclipse MAT分析20GB的heap dump文件 最后解析出来dump size只有1GB
2. 原因#xff1a;heap dump中包含许多unreachable objects Eclipse MAT的官方文档#xff0c;《Basic Tutorial》章节#xff0c;有对上图的Overview page做介绍 针对total size小…1. 问题描述 使用Eclipse MAT分析20GB的heap dump文件 最后解析出来dump size只有1GB
2. 原因heap dump中包含许多unreachable objects Eclipse MAT的官方文档《Basic Tutorial》章节有对上图的Overview page做介绍 针对total size小于file size的情况有专门说明 If the total size of the dump is much smaller than the size of the file it is possible that the heap dump contained many ‘garbage’ objects which would be discarded at the next garbage collection. See the unreachable objects query to examine these ‘garbage’ objects. 翻译过来就是 heap dump包含许多垃圾对象这些对象在下一次GC时可以回收一般情况下这些对象对于分析内存泄露来说是不重要的MAT会在解析heap dump的过程中删除这些对象 MAT对unreachable objects出现原因的分析 如果heap dump是因为OOM产生的JVM通常会进行GC操作以试图为新对象释放空间这时heap dump文件中将不会包含unreachable objects如果并未执行GC操作heap dump文件中就可能存在unreachable objects。 例如需要分配的空间非常大即使进行GC操作也无法满足需求或者由于其他事件触发了heap dump上述heap dump文件就是笔者通过jmap命令获得jmap -dump:formatb,filefile_name pid3. 如何查看unreachable objects
3.1 方法1基于已有的解析直接查看
3.1.1 Overview页面的link查看
在Overview页面通过 Unreachable Objects Histogram链接点击查看进入以后可以看到unreachable objects有19GB左右加上之前的1.4GB与整个heap dump文件的大小是一致的
3.1.2 通过 Query Browser 查看
通过工具栏Query Browser → \rightarrow → Java Basics → \rightarrow → Unreachable Objects Histogram查看unreachable objects
3.2 重新分析heap dump
清理缓存Window → \rightarrow → Heap Dump History → \rightarrow → 找到对应的heap dump文件 → \rightarrow → 右键Delete Index Files 允许MAT保留unreachable objectsWindow → \rightarrow → Preferences → \rightarrow → Memory Analyzer → \rightarrow → 勾选Keep unreachable objects → \rightarrow → Apply and Close 重新打开heap dump文件这次MAT将不会丢弃unreachable objects