When I am developing a jMonkey Engineer project as the example of the TestCanvas.java, I have encountered a problem. Even if I have exected the project with the stop mandate: app.stop(), but actually the project still occupied 400MB memory, so when I swiched to another scene by changing the appClass, the memory often encountered an overrun problem :java heap space. I really wonder how the problem can be solved, and any suggestions or answers will be welcomed. I am waiting online for your solutions!
Have you dropped all references to the application so that the garbage collector can clean it up?
Why are you using multiple applications rather than one application with multiple app states?
i am sorry ,I am a beginner. I have two scene . how could i change the scene from each other in one application?
Whether it is the first call rootNode.detachAllChildren() and then call rootNode.attachChild()? if so,could i get the space by calling rootNode.detachAllChildren()
Are you looking in your task manager for the memory? That will never drop, just raise til the max you set in the command line options. Again, normal java behavior :roll:
It’s not recommended to use detachAllChildren either.
Add your objects to the root node individually in initialize (or setEnabled) and then remove them individually after.
That way you don’t risk missing anything and/or accidentally removing something you shouldn’t.