title: Java: Size limitation on direct IntBuffer?
body: <p>I want to allocate a <strong>direct</strong> IntBuffer in Java with, say, a billion elements (64-bit system). The only way I know of is creating a direct ByteBuffer and viewing it as a direct IntBuffer. However, 4*1,000,000,000 exceeds Integer.MAX_VALUE, so my question is: how can I achieve my goal?</p>
  
  <pre><code>int numInts = 1_000_000_000;
  IntBuffer i = IntBuffer.allocate(numInts); // works!
  
  ByteBuffer bb = ByteBuffer.allocateDirect(4*numInts); // does NOT work: integer overflow
  IntBuffer ib = bb.asIntBuffer();
  System.out.println("This will never be printed");
  </code></pre>
  
  <p>Thanks a lot in advance,</p>
  
  <p>Markus</p>