iOS内存警告破坏了EAGLView

时间:2011-07-11 23:43:32

标签: ios memory-management opengl-es cocos2d-iphone eaglview

当我得到内存警告级别-1时,我的EAGLView开始吐出openGL错误行(502& 506)并且应用程序不会崩溃,但EAGLView变得无法响应。因为Cocos2d Director调用draw而错误是垃圾邮件。

这是内存警告回调的外观:

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    [[CCDirector sharedDirector] purgeCachedData];
}
  1. 502和506错误是什么意思,2。如果内存警告对opengl视图有任何影响,或者它是否会在我的代码中释放它不应该出现的内容?
  2. [更新]

    设法从cocos2d中获取一些详细日志:

    Received memory warning. Level=1
    cocos2d: deallocing <CCSprite = 002657B0 | Rect = (0.00,0.00,32.00,32.00) | tag = -1 | atlasIndex = -1>
    cocos2d: deallocing <CCTexture2D = 00265EA0 | Name = 4 | Dimensions = 32x32 | Coordinates = (1.00, 1.00)>
    cocos2d: deallocing <CCSprite = 00265A70 | Rect = (0.00,0.00,32.00,32.00) | tag = -1 | atlasIndex = -1>
    cocos2d: deallocing <CCSprite = 00266050 | Rect = (0.00,0.00,32.00,32.00) | tag = -1 | atlasIndex = -1>
    cocos2d: deallocing <LineNode = 0027A630 | Tag = -1>
    cocos2d: deallocing <LineNode = 0027AB90 | Tag = -1>
    cocos2d: deallocing <LineNode = 0027AF50 | Tag = -1>
    cocos2d: deallocing <LineNode = 0027B270 | Tag = -1>
    cocos2d: deallocing <LineNode = 00204820 | Tag = -1>
    cocos2d: deallocing <PaintingView = 00264970 | Tag = -1>
    cocos2d: deallocing <TutorialView = 00266570 | Tag = -1>
    cocos2d: deallocing <CCRenderTexture = 00266660 | Tag = -1>
    cocos2d: deallocing <CCTexture2D = 00266750 | Name = 5 | Dimensions = 1024x1024 | Coordinates = (1.00, 0.75)>
    cocos2d: deallocing <CCSprite = 00266960 | Rect = (0.00,0.00,1024.00,768.00) | tag = -1 | atlasIndex = -1>
    cocos2d: deallocing <EAGLView: 0x24aee0; frame = (0 0; 1024 768); transform = [0, -1, 1, 0, 0, 0]; autoresize = RM+BM; layer = <CAEAGLLayer: 0x2492c0>>
    cocos2d: deallocing <ES1Renderer = 0024D0E0 | size = 768x1024>
    modifying layer that is being finalized - 0x2fab80
    

    所以这几乎就是一切。看起来除了场景节点之外的所有东西都在消失。

1 个答案:

答案 0 :(得分:0)

至于OpenGL错误的含义,你可以参考你的OpenGL标题,它会告诉你502是GL_INVALID_OPERATION而506是GL_INVALID_FRAMEBUFFER_OPERATION

我无法从您的问题或提供的代码中看到任何内容,但我假设您要提前释放帧缓冲区(在运行时可能不应该这样做),或者Cocos2D在您调用时释放帧缓冲区purgeCachedData(后者我有点怀疑)并且没有完全重建它(如果有的话)。您可能需要检查EAGLView的实现,看看它是否设置为在需要时处理重新创建帧缓冲区(并查看是否存在您不必要地释放帧缓冲区的地方)。

也就是说,如果您收到内存警告,您可能也希望解决这些问题的来源。