请把代码粘贴在这里 ``` CCDataReaderHelper.cpp中已添加CC_SAFE_DELETE_ARRAY(pBytes); 但下面代码仍然出现内存泄露,如何解决??? bool CMoveCarMapLayer::initDice() { CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Animate/Dice/Map_Dice0.png", "Animate/Dice/Map_Dice0.plist", "Animate/Dice/Map_Dice.ExportJson"); m_pDiceAction = CCArmature::create("Map_Dice"); if (NULL == m_pDiceAction) { return false; } CCSize viewSize = CCDirector::sharedDirector()->getVisibleSize(); m_pDiceAction->setAnchorPoint(ccp(0,0)); m_pDiceAction->setPosition(ccp(viewSize.width/2, viewSize.height/2)); m_pDiceAction->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CMoveCarMapLayer::diceActionDone)); addChild(m_pDiceAction, 0, MapLayer_Tag_Dice); m_pDiceAction->getAnimation()->playByIndex(0); } void CMoveCarMapLayer::diceActionDone(CCArmature *armature, MovementEventType type, const char *str) { if(type == COMPLETE) { if (NULL == m_pDiceAction) { return; } m_pDiceAction->removeFromParent(); //m_pDiceAction->release(); CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo("Animate/Dice/Map_Dice.ExportJson"); CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile("Animate/Dice/Map_Dice0.plist"); CCTextureCache::sharedTextureCache()->removeTextureForKey("Animate/Dice/Map_Dice0.png"); //CCTextureCache::sharedTextureCache()->removeAllTextures(); } }
先要找到内存泄露位置吧,随便加不起作用的
— Begin quote from ____
引用第1楼dualface于2014-05-22 23:12发表的 :
先要找到内存泄露位置吧,随便加不起作用的
http://www.cocoachina.com/bbs/job.php?action=topost&tid=203015&pid=958718
— End quote
我注释了所有的代码只留下
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(“Animate/Dice/Map_Dice0.png”, “Animate/Dice/Map_Dice0.plist”, “Animate/Dice/Map_Dice.ExportJson”);
这个就是内存泄露的位置
现在是这样的
我只加:
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(“Animate/Dice/Map_Dice0.png”, “Animate/Dice/Map_Dice0.plist”, “Animate/Dice/Map_Dice.ExportJson”);
清空代码:
CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo(“Animate/Dice/Map_Dice.ExportJson”);
CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile(“Animate/Dice/Map_Dice0.plist”);
CCTextureCache::sharedTextureCache()->removeTextureForKey(“Animate/Dice/Map_Dice0.png”);
CCArmatureDataManager::sharedArmatureDataManager()->purge();
还是有Visual Leak Detector detected 7 memory leaks (4704 bytes).这么多的内存泄露
楼主 我也遇到同样的问题,请问你解决了么?