Cocos2D project with many scenes does not release memory properly

后端 未结 2 1503
一生所求
一生所求 2021-02-06 13:12

I\'ve got a great problem and I don\'t understand very well why occurs. This is the case:

  • Have a great project in Cocos2D with 10 scenes. Each scenes is a page of
2条回答
  •  别那么骄傲
    2021-02-06 14:08

    I was having a similar problem with memory retention and no leaks showing up in instruments. I couldn't get -(void) dealloc to even get called until I wrote the following into every scene's .m file:

    -(void) onExit {
        //unschedule selectors to get dealloc to fire off
        [self unscheduleAllSelectors];
        //remove all textures to free up additional memory. Textures get retained even if the sprite gets released and it doesn't show as a leak. This was my big memory saver
        [[CCTextureCache sharedTextureCache] removeAllTextures];
        [super onExit];
    }
    

    After implementing this, my memory was released after every replaceScene: was called. Hope this is of some use to you.

提交回复
热议问题