Releasing memory

I have a basic 2D application (swing components etc), where I would like to open and close 3D windows. Problem with Xith3D and Java3D is, that when I close these windows, it doesn’t release the memory.

Is there a way to make Xith3D or Java3D to release all the memory it used, without exiting the whole program?

java does this automaticly, no?. with his garbage collector?

For the java object, yes. For the native ressource, no (textures, VBO,…).

Well, the heap won’t shrink, so it’s not that visible in the Task Manager, but the used part of the heap will decrease (if you released all references)

I think he means in OpenGL, if memory is allocated (as in a C struct or array), it isn’t released, or is it? memory leaks are usually found in C/C++ because you have to deallocate memory even if there is no longer a reference to it. Probably more of a concern of LWJGL or JOGL than the scene graph API.

Java handles this well with the garbage collector, but it is possible to have objects persist without a desire for them to persist…meaning it doesn’t get garbage collected if there is a reference to the object.

Example:

public class mainLoop
{
Scene scene1;
Scene scene2;

scene1.start();
// if you are done with scene1, set it to null or else the
// object will linger without being garbage collected.
scene1 = null;
scene2.start();

}