Free Memory

Hi, I’m working on a test shoot em up with JMonkey, I’m currently using a pool to recicle object to get performance preventing the garbage collector has to release too much memory, this is fine for bullets shooted by the ship and by the enemies, but my problem is with the enemies it self, who is the correct way to manage the spatials? I have many enemies types. and I not found a spatial’s method to change the mesh and either any to release the resources. I think that simply lose the spatial’s referen (spatial = null;) to be released for the garbage collector cause that the game’s performance fall. Somebody can show how can do it? In others games frameworks, I just used a pool of enemy class, getting one of this when I needed and only change the image/animation that represent the enemy (in this framework, the image class have a release method) and change the class behavior.


In most cases it should be OK to just set it to null like you said. Are you actually experiencing performance issues with this approach?

No, but set it to null is a bad word to me, jajajajaaj, but if you say that it is the correct way, I will. I’m worrying for this issue why I want to run this game in Android devices and maybe that fall of performance when the garbage collector work be most evident.


Well yeah the android gc is not so good. However keep in mind taht if you synchronize or similar your pool you might actually slow stuff down, if you dont the pool is not threadsafe. (i dont know if you use multiple threads, this might be irrelevant)