0

我正在使用 Cocos2d 2.0 和 XCode 4.5.2,我确实想知道如何检测哪些 spritesheets/图像在特定时间仍在内存中。

示例:在场景中我加载 images.pvr.ccz spritesheet,然后调用 replaceScene 加载 Scene2。在 Scene2 运行时,我想查看 images.pvr.ccz 是否仍在内存中,因为每个场景的常驻内存都会增加。

我应该使用一些仪器工具还是应该在纹理缓存相关的类中添加一些断点?

我确实将图像添加到 frameCache,如下所示:

 [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"images.plist"];
        batchNode = [CCSpriteBatchNode batchNodeWithFile:@"images.pvr.ccz"];
        [self addChild:batchNode]; 

其他详细信息 - 不需要

我有以下行为:每次替换场景时,内存都会增加“x”MB,这可能对应于 spritesheet 大小。

我在每个场景的 init 方法中添加了这些调用,但是内存仍然增加:

    [CCAnimationCache purgeSharedAnimationCache];
    [CCShaderCache purgeSharedShaderCache];
    [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
4

1 回答 1

2
[[CCTextureCache sharedTextureCache] dumpCachedTextureInfo];

使用此调用查看当前加载到内存中的纹理。此外,如果要删除未使用的纹理,请使用

[[CCTextureCache sharedTextureCache] removeUnusedTextures];
于 2013-09-06T10:40:51.100 回答