Java OutOfMemory示例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java OutOfMemory示例相关的知识,希望对你有一定的参考价值。
This java code, when executed, throws OOM error.Java Console:
...
Exception in thread "main" java.lang.OutOfMemoryError
...
Heapdump Data:
...
1STHEAPFREE Bytes of Heap Space Free: 0
1STHEAPALLOC Bytes of Heap Space Allocated: 66666600
...
import java.util.ArrayList; import java.util.List; public class JavaOOM { oom1(); } private static void oom1() { List<String> myList = new ArrayList<String>(); for (long i=0; ; i++) { if (i%100000==0) { } } } }
以上是关于Java OutOfMemory示例的主要内容,如果未能解决你的问题,请参考以下文章