title: Memory usage of byte array in Java
body: <p>For a heuristic precomputed table i need a byte array with 1504935936 entries. This should take about 1.5 GB of Memory. </p>
  
  <pre><code>public class Main{
      public static void main(String[] args){
          byte[] arr = new byte[1504935936];
      }
  }
  </code></pre>
  
  <p>Why do I have a "OutOfMemoryError: Java heap space"-Exception, if I give the program 2 GB of RAM with</p>
  
  <pre><code>java -Xmx2048M Main
  </code></pre>
  
  <p>With </p>
  
  <pre><code>java -Xmx2153M Main
  </code></pre>
  
  <p>it works. Why does it need that much RAM?</p>