IPhone memory leak in Apple code

I am running leaks via tools in my iPhone app and I see a lot of leaks that don't seem to come from my code.

For example:

NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request  
                                                              delegate:operation];
operation.urlConnection = connection;
[connection release];

      

The leaks tell me the first line is missing 1008 bytes. This seems to be a pretty standard alloc initiative with release. Other leaks mentioned in UIKit and WebKit.

Is it possible that these leaks are actually in Apple wireframes, or most likely my code and leaks are not displaying information accurately?

+2


source to share


5 answers


It is possible that Apple has leaks (as unlikely as it may seem) - in the 3.0 GM release, several were implemented in the Core Data implementation.



What you should do when you suspect what it is, try to find a sample project from Apple that takes advantage of the features you are looking for or minify your own code as much as possible (create a minimal side project perhaps), then try it out with tools ... If you can reliably reproduce the leak, please file a bug to Apple.

+5


source


Do you work with NSZombieEnabled

? This will lead to false "leaks" in the Instruments.



+4


source


I think this is where your leak is taking place:

operation.urlConnection = connection;

      

You may not be doing proper memory management in operation

.

+2


source


Also, have you tried testing the app on a device instead of a simulator? The running instruments on the treadmill are not very accurate or reliable. Try this while http://www.tuaw.com/2009/09/08/xcode-3-2-daily-tip-analyzing-your-code/

0


source


Are you storing the reference to your delegate object somewhere else?

If you think about it, Leaks thinks that delegation is a leak if you don't have any other references to it, but it still persists. Also, how do you release the delegate (named operation) when the request is being made?

0


source







All Articles