How do you detect memory leaks on iPhone? How do you detect memory leaks on iPhone? xcode xcode

How do you detect memory leaks on iPhone?


I've written up a Tutorial on using Instruments to track iPhone memory leaks. I'm not sure if it will help you with what you're dealing with or not...couldn't hurt, though. :-)

http://www.streamingcolour.com/blog/tutorials/tracking-iphone-memory-leaks/


Change the view to "Extended Detail" on the instruments panel. This will show you the stack trace of each leaked object after you stop recording and select the leaked object.

You do see calls into the API, but what you are interested in is finding the last method of your application before the API calls, that is where the leak is.

A tip: turn on "gather memory contents" in the leaks view. Seeing the object values should also help finding where the problem is.

You don't want any leaks. 100 leaks is not typical (at least in my apps ;) Typical should be 0.


I'm not familiar with how to use Leaks, but you can always try running the Clang analyzer on your code to see if that'll turn anything up: http://clang.llvm.org/StaticAnalysis.html. It can often find many bugs that might lead to memory leaks.