Releasing memory

Hi everybody



I'm new to JME. I've been looking at the API for some time, but there are still some thing, I don't really understand.

How do I release the allocated memory of a loaded mesh node or a terrain node with all their vertex and index buffers? Is it enough to remove the node instances from the scene graph and wait until garbage collection cleans it up?

garfield said:

Hi everybody

I'm new to JME. I've been looking at the API for some time, but there are still some thing, I don't really understand.
How do I release the allocated memory of a loaded mesh node or a terrain node with all their vertex and index buffers? Is it enough to remove the node instances from the scene graph and wait until garbage collection cleans it up?

Someone else here told me JME 2.0 is not very good for memory management. For example, in my case, I rescaled a model and the previous VBO wasn't garbage-collected. You have to call manually the methods to delete the useless contents.

For example, if you want to delete all textures of a TextureState, you can call the method clearAllTextures() or deleteAll() if you want to remove them from the graphics card too.
gouessej said:

garfield said:

Hi everybody

I'm new to JME. I've been looking at the API for some time, but there are still some thing, I don't really understand.
How do I release the allocated memory of a loaded mesh node or a terrain node with all their vertex and index buffers? Is it enough to remove the node instances from the scene graph and wait until garbage collection cleans it up?

Someone else here told me JME 2.0 is not very good for memory management. For example, in my case, I rescaled a model and the previous VBO wasn't garbage-collected. You have to call manually the methods to delete the useless contents.

For example, if you want to delete all textures of a TextureState, you can call the method clearAllTextures() or deleteAll() if you want to remove them from the graphics card too.


or just set the values to null when ur done using them and call System.gc() before u initiate anything memory taxing
Bonechilla said:

or just set the values to null when ur done using them and call System.gc() before u initiate anything memory taxing

That doesn't help much with GPU resources though. The garbage collector can collect the mesh data on the CPU side but there's still VBO and DisplayLists stored on the GPU after that happens- this is where a memory leak forms.

I don't know if the following methods do what their names suggest…



  • deleteVBO(Buffer) - Method in class com.jme.renderer.jogl.JOGLRenderer

  • deleteVBO(int) - Method in class com.jme.renderer.jogl.JOGLRenderer

  • deleteVBO(Buffer) - Method in class com.jme.renderer.lwjgl.LWJGLRenderer

  • deleteVBO(int) - Method in class com.jme.renderer.lwjgl.LWJGLRenderer

  • deleteVBO(Buffer) - Method in class com.jme.renderer.Renderer. Checks the VBO cache to see if this Buffer is mapped to a VBO-id.

  • deleteVBO(int) - Method in class com.jme.renderer.Renderer. Attempts to delete the VBO with this VBO id.

  • deleteVBO(Buffer) - Method in class com.jme.system.dummy.DummyRenderer

  • deleteVBO(int) - Method in class com.jme.system.dummy.DummyRenderer

  • deleteVBOId(int) - Method in class com.jme.scene.state.jogl.records.RendererRecord

  • deleteVBOId(int) - Method in class com.jme.scene.state.lwjgl.records.RendererRecord



Though, even if they do not work, to delete VBO from Graphic Card Memory, OpenGL offers the method void glDeleteBuffersARB(GLsizei n, const GLuint* ids) of the Extension GL_ARB_vertex_buffer_object, that is (apparently) implemented in LWJGL as glDeleteBuffersARB(IntBuffer) - Static method in class org.lwjgl.opengl.ARBBufferObject.

So, theoretically you should be able to use one of the above solutions.