Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's nothing better than an empirical experiment to answer your question. I've wrote a Java program and run it while specifying the XMX flag (also used XMS=XMX to force the JVM pre-allocate all of the memory). To further protect against JVM optimizations, I've actively allocate X number of 10MB objects. I run a number of test on a number of JVMs increasing the XMX value together with increasing the number of MB allocated, on a different 32bit operating systems using both Sun and IBM JVMs, here's a summary of the results:</p> <p>OS:Windows XP SP2, JVM: Sun 1.6.0_02, Max heap size: 1470 MB<br> OS: Windows XP SP2, JVM: IBM 1.5, Max heap size: 1810 MB<br> OS: Windows Server 2003 SE, JVM: IBM 1.5, Max heap size: 1850 MB<br> OS: Linux 2.6, JVM: IBM 1.5, Max heap size: 2750 MB </p> <p>Here's the detailed run attempts together with the allocation class helper source code:</p> <p>WinXP SP2, SUN JVM:<pre> C:>java -version java version "1.6.0_02" Java(TM) SE Runtime Environment (build 1.6.0_02-b06) Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)</p> <p>java -Xms1470m -Xmx1470m Class1 142 ... about to create object 141 object 141 created</p> <p>C:>java -Xms1480m -Xmx1480m Class1 145 Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. </pre> WinXP SP2, IBM JVM<pre> C:>c:\ibm\jdk\bin\java.exe -version java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build pwi32devifx-20070323 (if ix 117674: SR4 + 116644 + 114941 + 116110 + 114881)) IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223ifx-2007 0323 (JIT enabled) J9VM - 20070322_12058_lHdSMR JIT - 20070109_1805ifx3_r8 GC - WASIFIX_2007) JCL - 20070131</p> <p>c:\ibm\jdk\bin\java.exe -Xms1810m -Xmx1810m Class1 178 ... about to create object 177 object 177 created</p> <p>C:>c:\ibm\jdk\bin\java.exe -Xms1820m -Xmx1820m Class1 179 JVMJ9VM015W Initialization error for library j9gc23(2): Failed to instantiate he ap. 1820M requested Could not create the Java virtual machine. </pre>Win2003 SE, IBM JVM<pre> C:>"C:\IBM\java" -Xms1850m -Xmx1850m Class1 sleeping for 5 seconds. Done.</p> <p>C:>"C:\IBM\java" -Xms1880m -Xmx1880m Class1 JVMJ9VM015W Initialization error for library j9gc23(2): Failed to instantiate he ap. 1880M requested Could not create the Java virtual machine.</pre> Linux 2.6, IBM JVM<pre> [root@myMachine ~]# /opt/ibm/java2-i386-50/bin/java -version java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build pxi32dev-20060511 (SR2)) IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223-20060504 (JIT enabled) J9VM - 20060501_06428_lHdSMR JIT - 20060428_1800_r8 GC - 20060501_AA) JCL - 20060511a</p> <p>/opt/ibm/java2-i386-50/bin/java -Xms2750m -Xmx2750m Class1 270</p> <p>[root@myMachine ~]# /opt/ibm/java2-i386-50/bin/java -Xms2800m -Xmx2800m Class1 270 JVMJ9VM015W Initialization error for library j9gc23(2): Failed to instantiate heap. 2800M requested Could not create the Java virtual machine. </pre></p> <p>Here's the code:</p> <pre><code> import java.util.StringTokenizer; public class Class1 { public Class1() {} private class BigObject { byte _myArr[]; public BigObject() { _myArr = new byte[10000000]; } } public static void main(String[] args) { (new Class1()).perform(Integer.parseInt(args[0])); } public void perform(int numOfObjects) { System.out.println("creating 10 MB arrays."); BigObject arr[] = new BigObject[numOfObjects]; for (int i=0;i &lt;numOfObjects; i++) { System.out.println("about to create object "+i); arr[i] = new BigObject(); System.out.println("object "+i+" created"); } System.out.println("sleeping for 5 seconds."); try { Thread.sleep(5000); }catch (Exception e) {e.printStackTrace();} System.out.println("Done."); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload