How to properly manage memory of CCParticleSystemQuad

How to properly manage memory of CCParticleSystemQuad
0.0 0

#1

Often I randomly create and add particles and don’t entirely understand the memory management best practices.
For instance:

ARCH_OPTIMAL_PARTICLE_SYSTEM *particles = CCParticleSystemQuad::particleWithFile(“particlePlist.plist”);
particles~~>setIsAutoRemoveOnFinish;
particles~~>setPosition(ccp(300,300));
addChild(particles);

results in a crash when in CCScheduler::removeUpdateFromHash element~~>target~~>selectorProtocolRelease(); is called.

If I do not setIsAutoRemoveOnFinish, it’ll crash when the parent node is removed.

I’ve got around this generally by keeping a reference to all created particle systems generated with a new () rather than the static method and ultimately calling

particle~~>unscheduleUpdate;
particle~~>removeFromParentAndCleanup(true);
particle->autorelease();

What is the proper way to instantiate and add a particle system that you’d like to clean up itself after finishing?

Thanks for any help.


#2

I really want to know about this too :frowning:


#3

I noticed in the example there’re commented out autoreleases, maybe this is a known issue?


#4

Any updates on this issue?


#5

I wanna know as well. I couldn’t create a particle system correctly in my code.