Large Memory Leak Using Reachability
Asked Answered
B

3

7

Using Instruments on the device it detects a 3.50 KB memory leak using Apple's Reachability 2.0 code in my app. The Leaked Object is GeneralBlock-3584. The leaks tool points to the following code:

- (BOOL) startNotifer
{
    BOOL retVal = NO;
    SCNetworkReachabilityContext    context = {0, self, NULL, NULL, NULL};
    if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
    {
        // THIS IS LINE OF CODE WHERE THE LEAK OCCURS:
        if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
        {
            retVal = YES;
        }
    }
    return retVal;
}

I'm pretty much using the Reachability example straight from the Apple example code so I can't figure out why this is happening or how I fix it.

Baffle answered 16/6, 2010 at 15:41 Comment(0)
T
6

GeneralBlock-3584 leaks are, according to official Apple statements on the developer forums (check http://devforums.apple.com, and mind your NDAs), not a real leak and in fact a bug in Instruments.

Thermophone answered 6/7, 2010 at 3:25 Comment(0)
P
1

Try wrapping your Reachability object with NSAutoReleasePool. If it still exist try narrowing done towards the Leak with the autoreleasepool.

Pydna answered 22/6, 2010 at 13:29 Comment(1)
Why? Unless you have forked your own thread, there is a NSAutoReleasePool around. Wrapping it would not help.Interpellant
D
0

I think this is a similar problem to this question . Actually it seems that its a Bug within CFNetwork and it depends on the OS, so there is no workaround. Apple has to fix it.

Doyon answered 25/6, 2010 at 18:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.