官方参考文档:http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Ftasks%2Fanalyzingthreads.html
代码
/**
* -XX:+PrintGC -Xloggc:gc.log
*
* VM args: -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
*/
public class HeapOOM {
static class OOMObject {
}
public static void main(String[] args) throws InterruptedException {
List<OOMObject> list = new ArrayList<>();
while(true){
list.add(new OOMObject());
// System.out.println("sleep");
// Thread.sleep(1000l);
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/8eac600203c92f4dcb6b8a0b65300e92.jpeg)
左方为控制台输出,右方为heap dump分析中线程信息。
![](https://i-blog.csdnimg.cn/blog_migrate/548a7a05f9857b9ffbf5079892caa070.png)
图二
图三
OQL实例
SELECT s.size, s.modCount FROM OBJECTS 258211 s
![](https://i-blog.csdnimg.cn/blog_migrate/032c051447ecd4067cf968ade011b298.png)
图四:结果