Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The analyzer is very good at finding the routine leaks that plague new programmers writing non-ARC code (failures to call <code>release</code>, returning objects of the wrong retain count, etc.). </p> <p>In my experience, there are a couple of types of memory issues it does not find:</p> <ul> <li><p>It cannot generally identify <a href="http://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//apple_ref/doc/uid/TP40011210-CH5-SW22">strong reference cycles</a> (a.k.a. <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/TP40004447-1000810">retain cycles</a>). For example, you add a repeating <code>NSTimer</code> to a view controller, unaware that the timer maintains a strong reference to the view controller, and if you don't <code>invalidate</code> the timer (or do it in the wrong place, such as the <code>dealloc</code> method), neither the view controller nor the timer will get released.</p></li> <li><p>It cannot find circular logic errors. For example, if you have some circular references where view controller A presents view controller B, which in turn presents a new copy of A (rather than dismissing/popping to get back to A).</p></li> <li><p>It cannot find many non-reference counting memory issues. While it's getting better in dealing with Core Foundation functions, if you have code that is doing manual memory allocations (such as via <code>malloc</code> and <code>free</code>), the static analyzer may be of limited use. The same is true whenever you're using non-reference counting code (e.g. you use SQLite <code>sqlite3_prepare_v2</code> and fail to call <code>sqlite3_finalize</code>).</p></li> </ul> <p>I'm sure that's not a complete list of what it doesn't find, but those are the common issues I see asked about on Stack Overflow for which the static analyzer will be of limited help. But the analyzer is still a wonderful tool (it finds issues other than memory issues, too) and for those individuals not using ARC, it's invaluable.</p> <p>Having said that, while the static analyzer is an under-appreciated first line of defense, you really should use Instruments to find leaks. See <a href="http://developer.apple.com/library/ios/#documentation/developertools/Conceptual/InstrumentsUserGuide/MemoryManagementforYouriOSApp/MemoryManagementforYouriOSApp.html">Locating Memory Issues in Your App</a> in the <em>Instruments User Guide.</em> That's the best way to identify leaks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload