Memory optimization problem

Hello there!

Let's explain my case. I am developing a sort of "adventure games maker" based on JME. The games produced are structured in scenes and grouped in chapters. When the scene (scenario) changes I dettach all the nodes in root node and attach the new nodes. The problem is memory grows too fast: for each change of scene the space in memory gets increased in aproximately 200Mb, and still there "forever". I've tryied invoking the garbage collector and I'm sure those nodes I dettach are not referenced any more. Am I missing something? When I've been playing for a not very long period of time I get an OutOfMemoryError, and my JVM is set to a minimum size of 512Mb.

Any ideas? Any help will be much appreciated.Thanks a lot

Try profiling your game using JProbe or JProfile. Pay special attention to the number of objects in memory and see if they are collected when your game switches scenes. You can also request the Garbage Collector to run from the profiling tools.

Please note that you can only request the Garbage Collector to run. There is no guarantee that it will actually run when you call System.gc().

The problem sounds like a memory leak to me. The profilers should help you find where it is.

Check that you are also flushing the textures. TextureCache.clear or something like that

Thanks for the help, but it did not work. Well, my question is… when you dettach a Node which is not referenced in any other place, will its resources be cleared as well? In case this does not happen, is there a method in JME which I can invoke to force some resources to be cleaned?