Beta2: memleak in Label::setTTFConfig

Beta2: memleak in Label::setTTFConfig
0.0 0


Calling setTTFConfig on an existing label object results in a memory leak. It calls SpriteBatchNode::initWithTexture and there you create a new Texture with โ€œnewโ€ the old one is never freed.

Would not have happened with smart pointers :slight_smile:

+1 for replacing cocos retain/release with smart pointers!


cocos2d-x 3.12. Bug is still here


And I have this leak


Commenting all inside this method (inside cocos2d-x sources) resolves the problem

void FontAtlasCache::purgeCachedData()
// auto atlasMapCopy = _atlasMap;
// for (auto&& atlas : atlasMapCopy)
// {
// atlas.second->purgeTexturesAtlas();
// }
// _atlasMap.clear();

I think this code is useless because all unused atlases automatically purges from atlas cache. But on receiving memory warning some atlases leaks because of


without releasing all the atlases. If we release all the atlases before cleaning, existing labels crashes.