Why cannot XCode static analyzer detect un-released retained properties?


I have this retained property declared like this:

@property (nonatomic, retain) NSMutableDictionary *codes;

then I synthesize this:

@synthesize codes;

I use the property like this:

self.codes = [NSMutableDictionary dictionary];

Then, I forget to say [codes release]; in my dealloc.

When I run Analyzer in XCode 4.3.2, this is not shown as an issue. My base SDK is iOS 5.1 and my compiler is Apple LLVM compiler 3.1

Why doesn't analyzer pick this up?


I imagine it's because the analyzer can't reliably detect retain/release issues across method/library boundaries.

You could conceivably pass ownership of your codes array to some external method or library which will release it later on for you. This would be bad practice because the receiving method should just retain it if it needs it, but I've seen this kind of thing done by inexperienced developers.

So you might see this in your class somewhere:

[SomeAPI takeThisArrayAndReleaseItLater:codes];

The analyzer has no way to know that your class is no longer responsible for releasing the array. To give you a warning would be incorrect, despite the fact that you are not following good memory management practices.

The analyzer is very good at only warning on real issues. I don't think I've ever seen a false-positive outside of betas builds, which is a good thing.


If you havent change anything from the configuration, whenver you target ios5+ you will automatically be using ARC (Automatic Reference Counting) which doesnt require you to release or retain.


The most disruptive change in iOS 5 is the addition of Automatic Reference Counting, or ARC for short. ARC is a feature of the new LLVM 3.0 compiler and it completely does away with the manual memory management that all iOS developers love to hate.


<em>This is a post by iOS Tutorial Team member Matthijs Hollemans, an experienced iOS developer and designer.</em>


  • Is a logical right shift by a power of 2 faster in AVR?
  • Custom XML file comparison
  • Iterating over every document in Lotus Domino
  • Store Room Database in Google Drive App Folder?
  • Contiki UDP packet transmission duration with CC2538
  • What is the right way to create a constant pool for inline assembly?
  • Mysql Data Directory on S3
  • visualize line-break and paragraph break with symbols in html similar to word
  • Swift: How can I bind an NSIndexPath to a addTarget
  • is DOM manipulation (with jQuery or else) async?
  • C# Return Type Issue
  • Simple dynamic call graphs in Java [closed]
  • Google Apps Script GmailApp - Label threads include off-label messages
  • Getting undefined symbol: __asan_memset when trying to use Clang address sanitizer
  • dompdf: white margin on A4 page
  • How can I add a gradient that spans two views?
  • The use of getSmallConstantTripCount method of Loop in LLVM
  • Lucene Query Boosting
  • Memory allocation profilers for managed and unmanaged code?
  • Inno setup hide installation items when switching from one installation to ther other
  • C++ how to handle tr1 and non-tr1 namespaces in portable code?
  • Cannot install ruby-1.9.2 in Mac OSX 10.8.1 due to symlink error
  • Unknown C# type
  • Correctly Importing Apache Commons Math Package
  • Facebook Messenger Platform - Detect user typing
  • hibernate sets dirty flag (and issues update) even though client did not change value
  • Using MouseListener to select a range of cells in a grid
  • SonarQube: Cannot deactivate rule with missing quality profile
  • Jquery popup on mouse over of calendar control
  • How to generate and display a QR Code in ionic 2
  • Atlas images wrong size on iPad iOS 9
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Trying to switch camera back to front but getting exception
  • Why winpcap requires both .lib and .dll to run?
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • Programmatically clearing map cache
  • reshape alternating columns in less time and using less memory
  • How can I use `wmic` in a Windows PE script?