Why does NetBeans declare low memory when running LWJGL-based Java applications several times?

He is currently experimenting with OpenGL in Java. After running the following test code for several cycles in NetBeans, I get a low memory error and the program exits. This problem occurs some time after starting the application after several successful cycles.

Why is this happening and how can it be fixed?

the code:

package test3d;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.input.Keyboard;

class ColoredTriangle {
    public void start() {
        try {
            Display.setFullscreen(true);
            DisplayMode dm = new DisplayMode(34,34);
           // Display.setDisplayMode(new DisplayMode(DisplayMode.get));
            Display.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
            System.exit(0);
        }

         // Init OpenGL
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GL11.glOrtho(-3, 3, -2.4, 2.4, -1, 1);
        GL11.glRotatef(0.0f,5.0f,1.0f,0.0f); 
        //GL11.glOrtho(0, 640, 480, 0, 1, -1);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        boolean quit = false;

        while (!quit) {         
            // Clear the screen.
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
            //GL11.glFrontFace(GL11.GL_CCW);
            // Begin drawing
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glColor3f(1.0f,0.0f,0.0f); //Red   

     /*
                GL11.glVertex3f(0.0f,0.0f, 0.0f);

                GL11.glVertex3f(0.0f,1.0f, 0.0f);

                GL11.glVertex3f(1.0f,1.0f, 0.0f);

                GL11.glVertex3f(1.0f,0.0f, 0.0f); //*/


                 GL11.glVertex3f(1.0f,0.0f, -1f);

                GL11.glVertex3f(1.0f,1.0f, -1f);

                GL11.glVertex3f(2.0f,1.0f, -1f);

                GL11.glVertex3f(2.0f,0.0f, -1f);

              GL11.glEnd();  



            Display.update();

            if (Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
                quit = true;
        }

        Display.destroy();
        System.exit(0);
    }
}
class Test3d
{
    public static void main(String args[]) {
        ColoredTriangle ct = new ColoredTriangle();
        ct.start();
    }

}
+5
source share
2 answers

This is a known issue with NetBeans.

The NetBeans JVM does not unload the LWJGL DLL after each loop that is invoked through the JNI through the LWJGL every time your application runs.

(. SO, ) Tomcat Application Server, -, JNI. JNI- - Tomcat, DLL, JNI, , . - Tomcat, Tomcat. , JNI- ; .

, NetBeans , :

+6

Linux Debian.

:

  • root
  • type crontab -e
  • * * * * * sync; echo 3 > /proc/sys/vm/drop_caches

. , NetBeans ( , ).

UNIX.

+1

All Articles