当我得到一个内存警告级别-1,我的EAGLView开始吐出行openGL错误(502 & 506),应用程序没有崩溃,但EAGLView变得没有响应。错误是垃圾邮件,因为Cocos2d主任调用抽签。
内存警告回调是这样的:
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[CCDirector sharedDirector] purgeCachedData];
}更新
设法从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所以这差不多就是一切了。看上去除了现场节点外,一切都在消失。
发布于 2011-07-12 00:40:58
至于OpenGL错误意味着什么,您可以参考您的OpenGL头,这将告诉您502是GL_INVALID_OPERATION,506是GL_INVALID_FRAMEBUFFER_OPERATION。
我从您的问题或提供的代码中看不到任何东西,但我假设您是过早地释放了框架缓冲区(您可能不应该在运行时这样做),或者Cocos2D在调用purgeCachedData (我对后者有点怀疑)时正在释放框架缓冲区,并且没有完全重新创建它(如果有的话)。您可能需要检查EAGLView的实现,看看它是否设置为在需要时处理重新创建框架缓冲区(并查看是否存在不必要的释放框架缓冲区的地方)。
也就是说,如果您收到了内存警告,您可能也想要处理这些警告的来源。
https://stackoverflow.com/questions/6658017
复制相似问题