Ios 替换场景继续增加内存使用和内存泄漏,如何处理?或者我应该如何在我的项目中启用ARC

Ios 替换场景继续增加内存使用和内存泄漏,如何处理?或者我应该如何在我的项目中启用ARC,ios,objective-c,memory-leaks,cocos2d-iphone,out-of-memory,Ios,Objective C,Memory Leaks,Cocos2d Iphone,Out Of Memory,我正在做一个cocos2d项目,这是一个有很多场景的游戏。 调用“替换场景”时,我使用 [scene2 removeAllChildrenWithCleanup:YES]; 在dealoc方法中。 此外,我还通过使用删除了所有未使用的精灵表 NSString *PngName = [atlas.AtlasName stringByAppendingString:@".png"]; NSString *PlistName = [atlas.AtlasName stringByA

我正在做一个cocos2d项目,这是一个有很多场景的游戏。 调用“替换场景”时,我使用

[scene2 removeAllChildrenWithCleanup:YES]; 
在dealoc方法中。 此外,我还通过使用删除了所有未使用的精灵表

    NSString *PngName = [atlas.AtlasName stringByAppendingString:@".png"];
    NSString *PlistName = [atlas.AtlasName stringByAppendingString:@".plist"];

    [[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFramesFromFile:PlistName];
    [[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFrameByName:PngName];

    [[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFrames];
当我查看我的

[CCSpriteFrameCache sharedSpriteFrameCache]  
,它向我显示,当我使用Instruments检查设备时,它会删除未使用的SpriteSheet,但不会释放内存。这将导致应用程序崩溃

经过多次尝试后,我想到在我的项目中使用ARC,但当我将其转换为ARC项目时,即使在执行了中所示的步骤之后

我的简历、董事会等都有很多错误。。
有人能帮我解决这个问题吗

检查在更改场景时是否正在删除触摸代理

尝试使用
CCSpriteFrameCache
purgeSharedSpriteFrameCache
removeeunusedspriteframes
removeeunusedtextures
。有关更多详细信息,请查看这些线程:


  • 希望有帮助

    当我检查描述时
    ,您是如何检查的?NSLog(@“%@,[[CCSpriteFrameCache sharedSpriteFrameCache]description]);谢谢,我忘了,但是在做了这件事之后,它还是继续吃着妈妈。我们能看看你是怎么做的吗?几周前我也有同样的问题,这就是我的罪魁祸首。在3-4个场景变换后,我的记忆完全耗尽了。是的,这是。你能告诉我你是如何克服这个问题的吗?我通过释放touch-delegate-onexit克服了这个问题。[[CCTouchDispatcher sharedDispatcher]removeDelegate:self];它会删除未使用的纹理,但当我尝试重新加载上一个场景时,它会给我错误的精灵帧名称,因为它无法访问纹理。由于释放了内存,需要时需要重新创建资源(如返回上一个屏幕)我清除了texturecache和spriteframe缓存,但它仍然会占用内存。我觉得我真的被卡住了。