1

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];
}
  1. 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. looks like everything except the scene node is disappearing.

Affian
  • 3,380
  • 5
  • 22
  • 26

1 Answers1

0

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.

  • I've just found out that cocos is deallocating pretty much everything I'm working with, the EAGLView included – Affian Jul 12 '11 at 00:52
  • That is some pretty hardcore purging. O_o –  Jul 12 '11 at 00:55
  • Is there some specific way I'm supposed to unload a EAGLView so that OpenGL doesn't use it anymore? – Affian Jul 12 '11 at 02:13
  • Well, why are you unloading the `EAGLView`? It's a small object, doesn't count towards much. If your application is going into the background, you can kill off the framebuffers, but everything else that's required for a quick startup should probably stick around until the application ends. For that matter, why is Cocos2D still trying to draw stuff when it shouldn't be? Are you neglecting to end the animation/loop/what have you for rendering? –  Jul 12 '11 at 02:16
  • What's happening is that the view controller that contains the GLview and gets pushed and loads the view and starts the director, then when it's unloaded (going back in the navigation stack) the EAGLView is unloaded and the director is stopped. when I go back into it sometimes it fires the memory warning and the above gets deallocated and causes the errors in opengl. – Affian Jul 12 '11 at 02:31
  • Based on that, I doubt I could really tell you what's going on without going in with a debugger when everything gets deallocated and just go line by line trying to figure out what's going wrong. –  Jul 12 '11 at 02:34