Memory Leak from Foundation & CFNetwork Library
I am using instruments to resolve memory leak issues for an app in iPhone. I just wanted to know if I have to resolve the leaks coming from Foundation and CFNetwork开发者_如何学Python Libraries. Specifically, the leaks are from:
1. NSCFString 2. NSConcreteData 3. General Block-3584 Since they do not directly point to the code that I have written, how should I resolve them, if I have to?Thanks.
It's almost certain that the memory leaks come from your code--there are almost no memory leaks in the Foundation libraries, providing you're testing on the device (there are memory leaks in the simulator, so you should always test on the device). It's not always immediately obvious where the leak comes from, and it's difficult to tell from your question, but I would guess it either comes from leaking an NSString
(NSStrings
are implemented with NSCFString
under the hood) or a network-related class like NSURLConnection
.
I experienced the same problems w.r.to memory leaks which were pointing to CFNetwork and Foundation framework. A small fix cleared all the memory leaks. While using aynchronous HTTP connection, I faced this problem.
Problem:
In the delegate, - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)
response,
I copied NSURLResponse and released.
Solution :
Dont copy and release NSURLResponse. Just use it as property asstype in your header file.
精彩评论