6 Replies Latest reply: Nov 18, 2007 11:38 PM by 807603 RSS

    Why do I get Out of memory error with ByteBuffer.allocateDirect()?

      When I run the following code

      public class Test

           public static void main(String[] args)
                ByteBuffer buffer = ByteBuffer.allocateDirect((int) Math.pow(2,26));          

      I get this error
      java.lang.OutOfMemoryError: Direct buffer memory.

      Form my understanding of allocateDirect It should allocate space directly in the OS memory space and not in the JVM space. Why do I still get the Out of memory from the

      I am using java 6 and eclipse 3.3.1

      Thank you