Is calling CFRunLoopRemoveSource necessary


#1

Hello,

I have implemented a socket to check for the ability to connect to a web service based on one of the examples in Advanced MAC OS. It’s pretty simple and looks like this:

    CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
    CFRelease(runLoopSource);

What I’m wondering is if it is necessary to later call CFRunLoopRemoveSource to avoid a resource leak or something similar? Part of what sparks this question is whether the call to CFRelease makes it unnecessary to later call CFRunLoopRemoveSource? The other thing that makes me ask is that, in the examples I’ve read, I haven’t seen any that call CFRunLoopRemoveSource.

Thanks,


#2

That’s fine. The release is removing your interest in the run loop source, and the run loop is responsible for retaining it until its done.