fork(1) download
  1. class Ideone
  2. {
  3. private static final int N = (int) (Runtime.getRuntime().maxMemory() * 0.5);
  4.  
  5. public static void main(String[] args) {
  6. memoryInScope();
  7.  
  8. //System.gc();
  9.  
  10. byte[] data = new byte[N];
  11. System.out.println("I love System.gc()");
  12. }
  13.  
  14. public static void memoryInScope() {
  15. byte[] data = new byte[N];
  16. for (byte b : data) ;
  17. }
  18. }
Runtime error #stdin #stdout #stderr 0.31s 4386816KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Ideone.main(Main.java:10)