new-frame handler increasing retain count

Home Forums Syphon Syphon Development – Developer new-frame handler increasing retain count

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #6418

    I have been using SyphonQC plugin but now I want to change it and use the new-frame handler so I can manage frames more accurately.

    changes in the function
    – (void)setClientFromSearchHavingLock:(BOOL)isLocked

    //newClient = [[SyphonClient alloc] initWithServerDescription:[matches lastObject] options:nil newFrameHandler:nil];

    newClient = [[SyphonClient alloc] initWithServerDescription:[matches lastObject] options:nil newFrameHandler:^(SyphonClient *client) {

    CGLContextObj cgl_ctx = [_context CGLContextObj];

    SyphonImage* image = [[client newFrameImageForContext:cgl_ctx] autorelease];


    [_frameQueue insertObject:image atIndex:0];

     This piece of code increases retain count of the “self” object so I am unable to release it on stopExecution function of the Plugin. I don’t know why is it happening despite trying to understand it several times 🙂



    Random guess: try specifying “__unsafe_unretained __block SyphonClient* client” in the new frame handler?


    Thanks actually it was a retain cycle issue and the solution is to use blockSelf->ivar to access all variables inside the block

    __block SyphonNameboundClient *blockSelf = self;
    Strange, I didn’t observe this issue in the Test Client Sample.


    Circumventing the retain rather misses the point – you don’t want your object being released while the block is still executing.

    As a note, once you call -stop on the client, the handler is released (and with it, anything it retained).


    I tried, but stop only removed the frame handler which did  not release the object it retained hence syClient dealloc is never called.

    Inside stopExecution

    [syClient lockClient];
    [syClient.client stop];
    [syClient unlockClient];
    [syClient release];



    Sorry yea, I was wrong – stop doesn’t release the handler.

    What I do in such cases is create a container object which has everything the handler needs to function which the handler and the client can both retain without causing a retain loop.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.