/ Published in: Java
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
...
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
...
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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) { } } } }
URL: http://www.javacodegeeks.com/2013/08/understanding-the-outofmemoryerror.html