views:

331

answers:

2

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 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.

A: 

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.

eman
Ok, but if the error is from my code, wouldn't I get the error library to be my app's name?
Lakshmie
Oftentimes, the chain of method and function calling can be convoluted, especially if you're dealing with any threading or asynchronous methods. For example, if you're dealing with an `NSURLConnection`, the library may show up as `CFNetwork` (I'm not sure if that's the case off the top of my head, it's just a hypothetical example). That being said, there are a few leaks in the frameworks, and it's possible that you ran into one: see http://stackoverflow.com/questions/478242/leak-generalblock-3584.
eman
I did a thorough check of my code. Everything that has been created using alloc has been released after its usage. Is there any other creation instance for which I need to release it?
Lakshmie
@Lakshmie: The only other times you need to `release` objects are for methods with `copy` or `new` in the method name (also, if you `retain` an object, you have to `release` it later). I may have spoken prematurely when I said it was "almost certainly" not framework code--the General Block-3584 leak looks like it may be from the framework.
eman
@eman: Thanks. I had checked for all of them. I still do get NSConcreteData and NSCFString leaks and none of them is reported from my app.
Lakshmie
A: 

The General Block-3584 leak looks like it may be from the framework.
         http://stackoverflow.com/questions/478242/leak-generalblock-3584

Thanks eman!

Lakshmie