Projects > cpp > Issues > Bug #949

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

CCParticleSystem and its children are not released correctly in tests

Bug #949 [Closed]
walzer@cocos2d-x.org 2012-01-16 02:18 . Updated over 11 years ago

in ParticleTest.cpp, for example

        CCParticleFlower *particle = new CCParticleFlower();  // ref = 1
        particle->init(); // ref = 2 because CCParticleSystem.cpp line 373, this->scheduleUpdateWithPriority(1);
        particle->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_stars1) );  // ref = 2

        particle->release();  // ref = 1
        // in this normal new->init->release sequence, *particle isn't released correctly  

An extra invoke is required:

        CCParticleFlower *particle = new CCParticleFlower();  // ref = 1
        particle->init(); // ref = 2 because CCParticleSystem.cpp line 373, this->scheduleUpdateWithPriority(1);
        particle->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_stars1) );  // ref = 2

        particle->unscheduleUpdate();  // VERY IMPORTANT! ref = 1;
        particle->release();  // ref = 0, released correctly.

CCSchedule may cause “unreleased memory block” in cocos2dx framework. We need to check them.

dumganhar 2012-02-07 07:54
  • Assignee set to dumganhar
dumganhar 2012-02-07 08:41

I didn’t find any memory leak in ParticleTest.

dumganhar 2012-02-29 04:08

I didn’t find your usage in ParticleTest. After you construct a particle, when you want to use the particle, you surely add it into a CCNode or CCNode’s subclass(e.g. CCLayer), at the time you don’t want to display it, you should invoke removeFromParentAndCleanup function which will call the unscheduleUpdate. Or when the particle’s parent node is destroyed, it will cleanup it’s children which contain your particle. So I don’t think this is a bug.

dumganhar 2012-02-29 04:11
  • Status changed from New to Closed
walzer@cocos2d-x.org 2012-05-25 08:00
  • Project changed from cocos2d-x to cpp
  • Category deleted (5)
  • Target version deleted (cocos2d-1.0.1-x-0.12.0)

Atom PDF

Status:Closed
Start date:2012-01-16
Priority:Normal
Due date:
Assignee:dumganhar
% Done:

0%

Category:-
Target version:-