0

What is the proper way of disposing objects that are in a pool?

I have a pool with ParticleEffects and I guess they need to be disposed.

So when should I do that?

I don't think it is a good idea to dispose that ParticleEffects when I put them back in the pool.

Should I keep all the references to objects I obtained from the pool in an Array and then dispose them when the programm is finished? Or is there a better way to to that?

Zezi Reeds
  • 1,286
  • 1
  • 16
  • 29

1 Answers1

1

May required more code for providing a proper answer. when your using the object pooling the best method for free up some memory the best practice is to free up the pool.

   if(particleEffectIsOutOfScreen) {

    objectPool.free(particleEffect);

    }

make a variable which always monitor the particle effect and when ever it is in out of screen use the above code to free up the memory. This is the best way to free up the memory during the pooling . For more specific answer more code is required