Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Memory Leaks in Apple's Code

I'm running leaks through Instruments on my iPhone app and I'm seeing a lot of leaks that don't appear to be coming from my code.

For example:

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

Leaks is telling me that the first line is leaking 1008 bytes. That seems to be a pretty standard alloc init with a release. Other leaks that are mentioned are in UIKit and WebKit.

Is it possible that these leaks are in fact in Apple's frameworks, or is more likely my code and leaks isn't showing the information accurately?

like image 904
Brian Avatar asked Apr 02 '26 01:04

Brian


2 Answers

It's entirely possible that Apple's frameworks have leaks in them (however unlikely it may seem) - there were several in the Core Data implementation for iPhone in the 3.0 GM release.

What you should do when you suspect such a thing is try to find a sample project from Apple that uses the functionality you're looking at or reduce your own code as much as possible (maybe build a minimal side project), then test that with Instruments. If you can reproduce the leak reliably, submit a bug to Apple.

like image 130
Tim Avatar answered Apr 04 '26 13:04

Tim


Are you running with NSZombieEnabled? That will cause fake "leaks" to show up in Instruments.

like image 31
nall Avatar answered Apr 04 '26 15:04

nall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!