Reachability icon indicating copy to clipboard operation
Reachability copied to clipboard

Memory leaks when Analyzing in iOS 9 (Xcode 7).

Open kishorekumarek opened this issue 9 years ago • 5 comments

Leaks showing in methods "reachabilityWithHostname:" and "reachabilityWithAddress:".

Line numbers 101 and 114 in Reachability.m

Potential leak of an object stored into 'ref'

Attached the screenshot of the issue.

screen shot 2015-09-25 at 12 20 07 am

kishorekumarek avatar Sep 24 '15 18:09 kishorekumarek

Duplicate of #114.

JimDabell avatar Oct 09 '15 16:10 JimDabell

You can write CFRelease(ref) below the issue row.

DavidYang1121 avatar Dec 23 '15 03:12 DavidYang1121

Sadly just releasing them like that won't work. It will result in an assertion fault:

Assertion failed: (lock), function SCNetworkReachabilityGetFlags, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/configd_Sim/configd-802.40.13/SystemConfiguration.fproj/SCNetworkReachability.c, line 1181.

Allendar avatar May 08 '16 11:05 Allendar

You need CFAutorelease(ref) instead of CFRelease(ref)

MacMark avatar May 14 '17 06:05 MacMark

Adding CFAutorelease(ref). And we need to remove the following from dealloc?

if(self.reachabilityRef)
  {
      CFRelease(self.reachabilityRef);
      self.reachabilityRef = nil;
  }

kuniaki avatar Aug 09 '17 00:08 kuniaki