title: Objective C release, autorelease, and data types
body: <p>I'm new to memory managed code but I get the idea pretty well.</p>
  
  <p>On taking my app through the leaks tool in XCode, I noticed I only had to clean up my custom objects, but not dynamically created arrays for example, so I figured those data types are autoreleased - makes sense since I only had to release the arrays I used as properties that had a (retain) on them.</p>
  
  <p>Then I noticed something peculiar :  I was getting a leak on a certain array initialized like this :</p>
  
  <pre><code>NSMutableArray *removals = [NSMutableArray new];
  </code></pre>
  
  <p>but not a similar one</p>
  
  <pre><code>NSMutableArray *removals = [NSMutableArray arrayWithCapacity:9];
  </code></pre>
  
  <p>Now, the reason one was set up with "new" is that it could have 0-99 items in it, whereas the other one I knew was going to always be 9.  Since both arrays are passed to the same method later based on user interaction, I was either getting a leak if I did not release  at the end of the method, or an exception if I did!</p>
  
  <p>I changed the first array to</p>
  
  <pre><code>NSMutableArray *removals = [NSMutableArray arrayWithCapacity:99];
  </code></pre>
  
  <p>and I get no leaks and don't have to release anything.  Can anyone explain?</p>