I found a problem that removeSpriteFramesFromFile and removeTextureForKey cannot work on Cocos2d-x 3.0 alpha.
`// on “init” you need to initialize your instance
bool MainScene::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
auto cache = SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("MainSceneLocalizedRes.plist", "MainSceneLocalizedRes.png");
SpriteBatchNode* mainSceneLocalizedResBatchNode = SpriteBatchNode::create("MainSceneLocalizedRes.png", 6);
this->addChild(mainSceneLocalizedResBatchNode);
}
void MainScene::onExit() {
SpriteFrameCache::getInstance()->removeSpriteFramesFromFile(“MainScenePubRes.plist”);
TextureCache::getInstance()->removeTextureForKey(“MainScenePubRes.png”);
}
I set a breakpoint on onExit, but I found removeSpriteFramesFromFile and removeTextureForKey cannot work to release memory.
//////cocos2d-x sources file////////////
void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist)
{
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
Dictionary* dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str());
removeSpriteFramesFromDictionary((Dictionary*)dict);
// remove it from the cache
set<string>::iterator ret = _loadedFileNames->find(plist);
if (ret != _loadedFileNames->end())
{
_loadedFileNames->erase(ret); /////////cannot be invoked
}
}
void TextureCache::removeTextureForKey(const std::string &textureKeyName)
{
auto it = _textures.find(textureKeyName);
if( it != _textures.end() ) {
(it->second)->release();/////////cannot be invoked
_textures.erase(it);/////////cannot be invoked
}
}`
How to release memory that allocated by addSpriteFramesWithFile & SpriteBatchNode::create?