开发者

Memory leakage with following code

开发者 https://www.devze.com 2023-02-23 04:30 出处:网络
Here is the code where I am having memory leaks: SCNetworkReachabilityRef reach = SCNetworkReachabilityCreateWithName(kCFAllocatorSy stemDefault, \"google.com\");

Here is the code where I am having memory leaks:

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

SCNetworkConnectionFlags flags;
SCNetworkReachabilityGetFlags(reach, &flags);

[flags re开发者_StackOverflowlease];
[reach release];

Those release don't do it.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消