title: Freeing Objects in Objective-C Blocks
body: <p>When using an Objective-C object that returns asynchronously with a completion handler, like AVAssetExportSession, is there anything wronmg with code like this:</p>
  
  <pre><code>AVAssetExportSession* exportSession = [[AVAssetExportSession alloc] initWithAsset: composition presetName: AVAssetExportPresetHighestQuality];
  [exportSession exportAsynchronouslyWithCompletionHandler: ^(void) {
      // export completed
      NSLog(@"Export Complete %d %@", exportSession.status, exportSession.error);
      [exportSession release];
      }];
  </code></pre>
  
  <p>Instruments reports exportSession as a leak.  I've also got a few classes of my own that use the same methodology and they also get reported as leaks.  </p>
  
  <p>From everything I've read it seems like the code should follow the proper memory management rules but something must be up.  I found a link to <a href="http://blog.lukhnos.org/post/897176864/cyclic-retention-pitfall-in-objective-c-blocks" rel="nofollow noreferrer">this article</a>, but I don't think I'm causing Cyclic Retention.</p>