Proper cleanup methods (my app running slow)

I have an app that generates so called organism which are basically blocks connected using hinge joints.



So I generate about 100 of those and each has about 3-10 blocks. That means about 300-1000 blocks on the scene.



Then I remove them all using: rootNode.detachAllChildren() and make new generation of organisms (again 300-1000 blocks).



The after new generation the application suddenly works slow.



Are there any other clean up methods that I’m not using?

You cannot have more than about 2000 geometries on the screen in jME3, combine them into single meshes.

But. If I remove them using rootNode.detachAllChildren() arent they “destroyed” and later garbage collected?

Yes, if you don’t keep a reference to them…

You mention “hinge joints” are you also using physics in some way?

Yes. Every “organism” is basically just a bunch of blocks connected on edges using hinge joints… Should I detach those from physics space somehow also?

Well everything you add you have to remove obviously…

So. I removed all RigidBodyControls and all HingeJoints and it’s still running in “slow motion”…



Any ideas? How can I debug/figure out what’s causing the problem?

Is the app fast after removing the old generation but before adding the new generation?



Really, there is no way for us to tell what’s wrong and this is where you will have to flex your debugging muscles and sort out which part of your code is triggering the issue. Other apps remove and add stuff all the time without slow-downs.

Try jvisualvm and determine what caues most of the load (your code, grafic stuff, physic stuff)

I tried using jvisualvm, but there’s nothing that would indicate memory problems as far as I know (btw, Im not an expert in this).



Here are jvisualvm screenshots if they tell you guys anything:

Does increasing the JVM heap size make it behave differently?

you are clearly having memory leaks somewhere…

curse my memory, it’s been so long since i have memory leaks that i stoped using the eclipse plugin i have… and i just checked the repository and it no longer exists -.-

well… there we go, a quick google and i got the site:

http://eclipse.org/mat/



this plugin works like a charm… it gives info about everything and even makes reports about posible memory leaks suspects…

i think you can even use it without eclipse…

all you really need is the dump… errrrr there was a way to set a key to trigger memory dump…



yes… here is it… in the getting started page of the memory analyzer:

http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump



that was some heavy memory excercise… xD… hope you can resolve your issues with this…



cheers…

btw, there could be other causes for your slowdowns, that do not include leaks… you may not be resetting all your values properly, or even unsuspectedly entering more times into X function… if say, your update loop is trying to update old data as well as the new one, you would have double the ammount of prosesing time, thus a slowdown…

try to comment out parts of your code that are doing updates till you find the culprit, then work your way down from there…

Thanks guys. As soon as I get from work today I’ll have a heavy debugging day I think… :smiley: