Eclipse Memory Analyzer使用

  Eclipse Memory Analyzer是Eclipse提供的内存分析工具,是一个快速、功能丰富的JAVA heap分析工具,它可以帮助查找java进程dump后的文件。

下载:https://www.eclipse.org/mat/downloads.php
Mac中打开会报错,参看提示的错误log有如下内容:

…
java.lang.IllegalStateException: The platform metadata area could not be written: 
/private/var/folders/k4/knjt7v5x59l25z_tqmvg094r0000gn/T/AppTranslocation/3CBB3175-DD9A-4A3A-B93F-898BA4445384/d/mat.app/Contents/MacOS/workspace/.metadata. 
By default the platform writes its content under the current working directory when the platform is launched. 
Use the -data parameter to specify a different content area for the platform.
…

原因是那个文件是只读文件,解决方案是 选中 mat图标->右键->显示包内容->Contents->Eclipse->MemoryAnalyzer.ini,编辑文件MemoryAnalyzer.ini

-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
-data
/Users/zero/logs
--launcher.library
../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.700.v20180518-1200
-vmargs
-Xmx4096m
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XstartOnFirstThread

添加data参数,注意data参数和路径必须在两个不同的行,data参数必须放在Laucher之前。为了防止dump文件太大MAT打不开,顺带把-Xmx调大一点。


Overview:以饼状图的形式列举出了程序内存消耗的一些基本信息,其中每一种不同颜色的饼块都代表了不同比例的内存消耗情况。
Histogram:可以列出内存中的对象,对象的个数以及大小。
Dominator Tree:可以列出那个线程,以及线程下面的那些对象占用的空间。
Top consumers:通过图形列出最大的object。
Leak Suspects:通过MA自动分析泄漏的原因。

猜你喜欢

转载自blog.csdn.net/zero__007/article/details/85176922