JVM-内存溢出场景模拟

1.例子代码

public class OomDemo {

public static void main(String[] args) {
	// TODO Auto-generated method stub

	List<String> list=new ArrayList<>();

	for(;;) {
		list.add(new String());
	}

// List list=new ArrayList<>();
//
// for(;😉 {
// list.add(new Demo());
// }

}

}

2.异常截图

3.eclipse jvm 配置

-XX:+HeapDumpOnOutOfMemoryError -Xms20m -Xmx20m

4.查看dump文件

工具eclipse memory analyer

posted @ 2019-06-22 12:38  potatoyam  阅读(247)  评论(0编辑  收藏  举报