Issue with Particle system

Hi,

I’m having a strange issue with particle systems that I’m trying to work out.

I have an amount of particle systems used in a scene. Each type of particle is stored in a CCArray, and all CCArrays are stored in a CCDictionary, like this:

particleContainer_ = CCDictionary::create();
particleContainer_>retain;
>
CCArray *array1 = CCArray::create;
particleContainer_
>setObject(array1, key1);
>
CCArray array2 = CCArray::create;
particleContainer_>setObject;
>
>
CCParticleSystemQuad *particle1 = CCParticleSystemQuad::create;
array1
>addObject;
>
CCParticleSystemQuad
particle2 = CCParticleSystemQuad::create(type);
array2->addObject(particle2);

etc.

Particles are not retained anywhere, so they should be autoreleased. At the release of the scene I call:

CC_SAFE_RELEASE(particleContainer_);

Problem is that when checking allocations in the XCode instruments I am seeing a heap growth from the particle systems each time I load and exit the scene, so they don’t seem to be getting released. Anyone know what could be wrong? Thanks

1 Like

Does your particleContainer_ dictionary was added to something else as a children? The CC_SAFE_RELEASE only release the object one time.

Steven Lee wrote:

Does your particleContainer_ dictionary was added to something else as a children? The CC_SAFE_RELEASE only release the object one time.

No it is only retained once, thats what makes it so strange :confused:

1 Like

I found a workaround, still not sure why it is happening though.

I was keeping the particles in arrays, and adding them to the active scene using addChild when I needed them. When they were no longer needed they were removed from parent. Adding the particles to the start at init and not adding/removing them solved the problem.

1 Like