OutOfMemory in 1.1 b10

[edit: See reply… This was caused by a bug in the jvm]

java.lang.OutOfMemoryError
at java.nio.Bits.reserveMemory(Bits.java:618)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:95)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:285)
at net.java.games.jogl.impl.mipmap.Mipmap.gluBuild2DMipmaps(Mipmap.java:691)
at net.java.games.jogl.impl.GLUImpl.gluBuild2DMipmapsJava(GLUImpl.java:587)
at net.java.games.jogl.impl.GLUImpl.gluBuild2DMipmaps(GLUImpl.java:783)
at class.bh.a(SourceFile:139)

From the sourcecode for javax.nio.Bits (java 1.4.2):

    // -- Direct memory management --

    // A user-settable upper limit on the maximum amount of allocatable
    // direct buffer memory.  This value may be changed during VM
    // initialization if it is launched with "-XX:MaxDirectMemorySize=<size>".
    private static long maxMemory = VM.maxDirectMemory();
    private static long reservedMemory = 0;
    private static boolean memoryLimitSet = false;

    // These methods should be called whenever direct memory is allocated or
    // freed.  They allow the user to control the amount of direct memory
    // which a process may access.  All sizes are specified in bytes.
    static synchronized void reserveMemory(long size) {
      if (!memoryLimitSet && VM.isBooted()) {
          maxMemory = VM.maxDirectMemory();
          memoryLimitSet = true;
      }
      if (reservedMemory + size > maxMemory) {
          System.gc();
          if (reservedMemory + size > maxMemory)
            throw new OutOfMemoryError();
      }
      reservedMemory += size;
    }

    static synchronized void unreserveMemory(long size) {
      if (reservedMemory > 0) {
          reservedMemory -= size;
          assert (reservedMemory > -1);
      }
    }

Of course, there’s no way of setting -XX:MaxDirectMemorySize= in java 1.4.2 webstart, so we’re stuck with whatever the default value is.

of course, immediately after posting that, I found this:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4879883

Nevermind me.