I have noticed that Cocos2d’s ParticleSystem uses image->release() in initWithDictionary method. CCImage is not an autoreleased object and I think C++'s delete should be used instead of releasing it. I have checked out cocos v4 and v3 and this hasn’t been changed. I added the code snippet from CCParticleSystem.cpp. I have checked the memory leaks with Ref::printLeaks method.
// For android, we should retain it in VolatileTexture::addImage which invoked in Director::getInstance()->getTextureCache()->addUIImage()
image = new (std::nothrow) Image();
bool isOK = image->initWithImageData(deflated, deflatedLen);
CCASSERT(isOK, "CCParticleSystem: error init image with Data");
CC_BREAK_IF(!isOK);
setTexture(Director::getInstance()->getTextureCache()->addImage(image, _plistFile + textureName));
image->release();
4 posts - 2 participants