代码之家  ›  专栏  ›  技术社区  ›  Frank

有人使用cocos2d有内存泄漏吗?

  •  2
  • Frank  · 技术社区  · 15 年前

    我在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:)];

    这只发生在设备中,而不是在模拟器中。 不确定是否有人收到这个?

    1 回复  |  直到 13 年前
        1
  •  0
  •   eemceebee    15 年前

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