gpt4 book ai didi

iOS 内存警告破坏 EAGLView

转载 作者:行者123 更新时间:2023-12-01 17:01:18 25 4
gpt4 key购买 nike

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

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

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

  • [更新]

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

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

    最佳答案

    至于 OpenGL 错误是什么意思,您可以引用您的 OpenGL header ,它会告诉您 502 是 GL_INVALID_OPERATION 506 是 GL_INVALID_FRAMEBUFFER_OPERATION .

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

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

    关于iOS 内存警告破坏 EAGLView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6658017/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com