一 :安装php
一、Memory Analyzer 插件下载地址:http://www.eclipse.org/mat/downloads.phpeclipse
二、将下载的文件解压到MyEclipse的 dropins 文件夹下;测试
建立和文件夹同名的.link文件,文件中的内容就写上对应的地址(地址使用\\ 或者 /)spa
三、重启MyEclipse,便可在window---->preferances中看到Memory Analyzer选项。插件
二 :使用debug
一、内存溢出代码:深刻理解JVM中例子code
public class Test { static class OOMObject{ } public static void main(String[] args) { List<OOMObject> list = new ArrayList<OOMObject>() while(true){ list.add(new OOMObject()) } } }
二、设置运行参数blog
项目右键,debug as => debug configrationsip
写入下面配置项:设置内存
-verbose:gc -Xms20m -Xmx20m
-XX:+HeapDumpOnOutOfMemoryError
三、运行测试代码,舒心项目会出现一个.hprof文件(这是堆转储快照文件),双击,默认方式打开