官方参考文档: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);
}
}
左方为控制台输出,右方为heap dump分析中线程信息。
图二
图三
OQL实例
SELECT s.size, s.modCount FROM OBJECTS 258211 s
图四:结果
时间: 2024-10-23 21:57:25