iOS memory warning breaking EAGLView
When I get a memory warning level-1 my EAGLView starts spitting out lines of openGL errors (502 & 506) and the app doesn't crash but the EAGLView becomes unresponsive. the errors are spamming out because of the Cocos2d Director calling draw.
This is how the memory warning callback looks:
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[CCDirector sharedDirector] purgeCachedData];
}
- What do the 502 and 506 errors mean, and 2. should there be any effect on the opengl view from memory warnings or is it releasing something it shouldn't in my code?
[Update]
managed to get some verbose logs out of 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
So that's pretty much everything. look开发者_运维知识库s like everything except the scene node is disappearing.
As for what the OpenGL errors mean, you can refer to your OpenGL headers, which would tell you that 502 is GL_INVALID_OPERATION
and 506 is GL_INVALID_FRAMEBUFFER_OPERATION
.
I can't see anything from your question or provided code, but I'm assuming that either you are releasing your framebuffer prematurely (which you probably shouldn't do at runtime), or Cocos2D is releasing your framebuffer when you call purgeCachedData
(the latter of which I'm sort of doubtful of) and failing to recreate it completely (if at all). You may want to check your implementation of EAGLView
and see if it's set up to handle recreating the framebuffer when needed (and see if there's somewhere that you're releasing the framebuffer unnecessarily).
That said, if you're getting memory warnings, you might want to address the source of those as well.
精彩评论