title: Why does ARC retain method arguments?
body: <p>When compiling with ARC, method arguments often appear to be retained at the beginning of the method and released at the end. This retain/release pair seems superfluous, and contradicts the idea that ARC "produces the code you would have written anyway". Nobody in those dark, pre-ARC days performed an extra retain/release on all method arguments just to be on the safe side, did they?</p>
  
  <p>Consider:</p>
  
  <pre><code>@interface Test : NSObject
  @end
  
  @implementation Test
  
  - (void)testARC:(NSString *)s
  {
    [s length];  // no extra retain/release here.
  }
  
  - (void)testARC2:(NSString *)s
  {
    // ARC inserts [s retain]
    [s length];
    [s length];
    // ARC inserts [s release]
  }
  
  - (void)testARC3:(__unsafe_unretained NSString *)s
  {
    // no retain -- we used __unsafe_unretained
    [s length];
    [s length];
    // no release -- we used __unsafe_unretained
  }
  
  @end
  </code></pre>
  
  <p>When compiled with Xcode 4.3.2 in release mode, the assembly (such that I'm able to understand it) contained calls to <code>objc_retain</code> and <code>objc_release</code> at the start and end of the second method. What's going on?</p>
  
  <p>This is not a huge problem, but this extra retain/release traffic does show up when using Instruments to profile performance-sensitive code. It seems you can decorate method arguments with <code>__unsafe_unretained</code> to avoid this extra retain/release, as I've done in the third example, but doing so feels quite disgusting.</p>