views:

286

answers:

2

I guess that the "# Net" column is the most interesting, although I don't really understand what that's supposed to mean. Total number of currently allocated objects? It changes all the time, even if I don't do anything.

Are there any good "rules of thumb" to see if there is an memory leak?

+3  A: 

You may find this tutorial helpful: http://www.mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial/.

As well, there's a static analyzer available that analyzes your source code directly: http://clang.llvm.org/StaticAnalysisUsage.html.

Curt Sampson
clang is awesome. I make it a policy to make sure there are no issues before I commit changes.
freespace
Thanks for the tip on clang! I didn't know about that and it's really nifty. Just FYI, however, I needed to specify both the -configuration and -sdk flags to xcodebuild to get it to work properly with clang.
n8gray
+2  A: 

In general, if the memory footprint of your app continues to grow after you've gone through all your basic operations once or twice then you probably have a memory leak. The total memory footprint is in the "Net Bytes" column. The "Overall" columns include every allocation in the entire run of your program, while the "Net" columns subtract out deallocations.

However, the "Leaks" instrument is much better than ObjectAlloc for catching memory leaks in my experience. Just select "Run > Start With Performance Tool > Leaks" in Xcode and run through your program for a while. If Leaks starts showing leaked blocks then you've got a leak. It will tell you the stack trace of every allocation, retain, release, and free of any leaked block, and you can double-click on the stack trace to jump to that spot in your code. Just make sure to turn on the "extended detail view" by clicking on the little half-shaded square button at the bottom of the window, just to the left of the "Leaked Blocks" label. To get the list of allocations, click the little "triangle in a circle" disclosure triangle that appears next to the block's address when you hover the mouse over it.

n8gray