1

当我收到 1 级内存警告时,我的 EAGLView 开始吐出一行 openGL 错误(502 和 506),并且应用程序没有崩溃,但 EAGLView 变得无响应。由于 Cocos2d Director 调用 draw,错误正在发送。

这是内存警告回调的样子:

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

[更新]

设法从 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

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

4

1 回答 1

0

至于 OpenGL 错误的含义,您可以参考您的 OpenGL 标头,它会告诉您 502 isGL_INVALID_OPERATION和 506 is GL_INVALID_FRAMEBUFFER_OPERATION

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

也就是说,如果您收到内存警告,您可能还需要解决这些警告的来源。

于 2011-07-12T00:40:58.487 回答