What kind of indicators do I have to look at in Instruments app and ObjectAlloc, to see if I have memory leaks in my app?

StackOverflow https://stackoverflow.com/questions/904953

Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top