3

をプレイしてください、私は最近、私のOpenGLのアニメーションを再描画するCVDisplayLinkにNSTimerを使用してからの切り替えが、私はARCがオンで、それが動作することはほとんど問題が持っている:CVDisplayLink +自動参照カウントが一緒にうまく

/* 
* This is the renderer output callback function. 
*/ 
static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) 
{ 
    // now is the time to render the scene 
    [((__bridge BDOpenGLView*)displayLinkContext) setNeedsDisplay:YES]; 
    // always succeeds, because we don't actually do anything here anyway 
    return kCVReturnSuccess; 
} 

表示リンク・コールバック機能は、私はコールバックで内selfを使用することができない

// set the renderer output callback function 
CVDisplayLinkSetOutputCallback(displayLink, &displayLinkCallback, (__bridge void*)self); 

ためのパラメータとして使用する、Cで書かれなければならないが、((__bridge BDOpenGLView*) displayLinkContext)を使用してメモリリークを生成する:

objc[29390]: Object 0x1001b01f0 of class NSConcreteMapTable autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug 

自分でNSAutoreleasePoolを設定する必要がありますが、私はARCをオンにすることができません。

私に何か不足していますか?

答えて

6

サラウンド新しい@autoreleasepoolブロックとコード:

@autoreleasepool { 
    // your c callback code here 
} 
+0

は、私は今、愚かな感じ:Dのおかげで:) – cargath

+0

私はヶ月前にアークに比べていくつかのGCコードを移行して、このまったく同じ事を打ちます。私はブロックに慣れていて、明示的な自動解放プールは必要ないという事実に慣れています(http://stackoverflow.com/questions/4141123/do-you-need-to-create-an-nsautoreleasepool-within-a -block-in-gcd)、私はCVDisplayLinkがそのコールバックで使用するバックグラウンドスレッドの作成を忘れていました。 –

関連する問題