【问题标题】:Is anyone have memory leaks using cocos2d?有人使用 cocos2d 有内存泄漏吗?
【发布时间】:2009-11-26 18:30:51
【问题描述】:

我检测到内存泄漏,特别是在 director 对象的 startAnimation 方法中。

- (void) startAnimation
{
    if ( gettimeofday( &lastUpdate, NULL) != 0 ) {
        CCLOG(@"cocos2d: DisplayLinkDirector: Error on gettimeofday");
    }

    // approximate frame rate
    // assumes device refreshes at 60 fps
    int frameInterval   = (int) floor(animationInterval * 60.0f);

    CCLOG(@"cocos2d: Frame interval: %d", frameInterval);

    displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(preMainLoop:)];
    [displayLink setFrameInterval:frameInterval];
    [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}

它泄漏在:[NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(preMainLoop:)];

这只发生在设备中而不是模拟器中。 不确定其他人是否得到这个?

【问题讨论】:

  • 你使用的是新的 0.9.0 alpha 版本的 cocos2d 吗?我在 0.8.2 中找不到这个
  • 我使用的是 0.8.2,这仅在我将其编译到实际设备中而不是在模拟器中时发生。

标签: objective-c memory-leaks cocos2d-iphone


【解决方案1】:

你真的应该更新到最新版本,0.99 有很多改进

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    • 2012-08-21
    • 1970-01-01
    • 2019-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多