Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory leakage with following code

Here is the code where I am having memory leaks:

SCNetworkReachabilityRef reach = SCNetworkReachabilityCreateWithName(kCFAllocatorSy stemDefault, "google.com"); 

SCNetworkConnectionFlags flags;
SCNetworkReachabilityGetFlags(reach, &flags);

[flags release];
[reach release];

Those release don't do it.

like image 814
lilzz Avatar asked Apr 17 '26 05:04

lilzz


1 Answers

First of all, the SCNetworkConnectionFlags is an enum, so it doesn't have to be released. Remove the [flags release] and problem solved.

Moving on, the SCNetworkReachabilityRef is released through

CFRelease(reach);
like image 109
Gustav Larsson Avatar answered Apr 19 '26 00:04

Gustav Larsson