title: Capturing the output of a video file for frame by frame processing
body: <p>I am trying to grab the individual frames from a video file (7 seconds long) and running into huge memory issues.  </p>
  
  <p>I am loading up an asset with AVURLAsset then creating an <code>AVAssetReader</code> and an accompanying <code>AVAssetReaderTrackOutput</code> (with pixel format <code>kCVPixelFormatType_32BGRA</code>).  Everything seems to work just fine except for the massive memory hit that ends up getting my app shutdown by the OS almost instantly.</p>
  
  <p>As soon as I call <code>[myAVAssetReader startReading]</code> memory spikes up 25 megs and it only gets worse from there. </p>
  
  <p>Even if I just call <code>[myAVAssetReader startReading]</code> then <code>[myAVAssetReader cancelReading]</code> and <code>[myAVAssetReader release]</code> the 25 megs is never released.  It only gets worse once I go into a loop gathering frames:</p>
  
  <pre><code>CMSampleBufferRef sample = [output copyNextSampleBuffer];
  
      while( sample != NULL )
      {
           CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer( sample );
  
           // Lock the image buffer
           CVPixelBufferLockBaseAddress( imageBuffer, 0 );
  
              // Do stuff with the imageBuffer
  
           // We unlock the  image buffer
           CVPixelBufferUnlockBaseAddress( imageBuffer, 0 );
  
           // done with the sample
           CFRelease( sample );
  
           sample = [output copyNextSampleBuffer];
      }
  </code></pre>
  
  <p>Any clues as to how to free the memory that the <code>AVAssetReader</code> is using?</p>