title: How to force JVM 64-bit to use more than 4GB for the heap?
body: <p>This is quite puzzling, 64-bit OS, 64-bit JDK, 16GB of RAM, and I am unable to use more than 4GB for the heap. Here is how I start the program (my program is in Scala, but it is based on JVM):</p>
  
  <pre><code>/usr/lib64/jvm/java/bin/java -d64 -Xms512m -Xmx10g ...jars go on
  </code></pre>
  
  <p>And when I read the total memory within my program (<code>Runtime.getRuntime().totalMemory()</code>)... the reading is "4242MB".</p>
  
  <p><strong>QUESTION</strong> -- how to force JVM to use the amount memory I already provided (10 GB)?</p>
  
  <p><code>java -version</code> says:</p>
  
  <pre><code>java version "1.6.0_29"
  Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
  Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
  </code></pre>
  
  <h2>Update 1</h2>
  
  <p><code>maxMemory</code> returns "9102MB", so now there is the question where the difference went (both 1GB and 5GB), and how to use all maximum memory (my program crashes, because it requires 2 chunks of ~3GB, and 4GB in total is not enough).</p>
  
  <h2>Update 2</h2>
  
  <p>Now, I put all the readings before and after my allocation, and surprise, surprise, first reading of total memory was 4GB, the second too, but third one peaked to 8GB. I am glad, total memory can increase all of the sudden, because it solves my problem, but I don't understand it.</p>