title: 64 bits JVM Could not reserve enough space for object heap
body: <p>I have a Windows 7 laptop, with 16GB RAM. When I run multiple java servers I get OutOfMemory error, however, windows task manager shows that I still have 6GB of free physical memory left. It seems like to me that my JVM can only allocate ~2GB heap for all running java apps.</p>
  
  <p>So I wrote some very simple Java code:</p>
  
  <pre><code>public class HelloWorld {
      public static void main(String[] args) {
           for(;;) System.out.println("Hello, World");
      } 
  }
  </code></pre>
  
  <p>My -jvm version:</p>
  
  <pre><code>$ java -version
  java version "1.8.0_111"
  Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
  Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
  </code></pre>
  
  <p>JAVA_HOME "C:\Program Files\Java\jdk1.8.0_111"</p>
  
  <p>JRE_HOME "C:\Program Files\Java\jre1.8.0_111"</p>
  
  <p>I did a simple <code>java -Xmx256m -Xms256m HelloWorld</code> and it worked as expected, however when I switched to <code>java -Xmx2048m -Xms2048m HelloWorld</code> I get the following:</p>
  
  <pre><code>Error occurred during initialization of VM
  Could not reserve enough space for object heap
  </code></pre>
  
  <p>I tried multiple JDKs but none of them are working. Both windows and JVM are in 64 bits. </p>
  
  <p>What can I do to fix this problem? </p>