2010-01-21 28 views

Répondre

0

Got the répondez à cette question SO link

0

Je n'ai pas JRockit mais je devrais essayer quelques valeurs de l'option -Xmx. Sur ma machine virtuelle Java de la limite est 1610 Mo:

c:\tmp>java -version 
java version "1.6.0_18" 
Java(TM) SE Runtime Environment (build 1.6.0_18-b07) 
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing) 

c:\tmp>java -Xmx1610m mem_test 
1552 MB Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 
    at mem_test.main(mem_test.java:15) 

c:\tmp>java -Xmx1611m mem_test 
Error occurred during initialization of VM 
Could not reserve enough space for object heap 
Could not create the Java virtual machine. 

Je l'ai testé avec un tel programme, vous pouvez voir combien de mémoire vous application peut allouer de tas disponible à JVM:

import java.util.ArrayList; 
import java.io.*; 

class mem_test 
{ 
    public static void main(String[] args) 
     { 
     ArrayList<byte[]> big_list = new ArrayList<byte[]>(); 
     int max = 0; 
     int i = 0; 
     while (true) 
      { 
      ++i; 
      big_list.add(new byte[1024 * 1024]); 
      max = i; 
      if (i % 16 == 0) 
       System.out.print("\r" + i + " MB "); 
      } 
     } 
}