title: CFRelease on CMSampleBufferRef - Why do I need to call this?
body: <pre><code>CMSampleBufferRef sampleBuffer = [assetOutput copyNextSampleBuffer];
  CMBlockBufferRef buffer = CMSampleBufferGetDataBuffer(sampleBuffer);
  CMBlockBufferAppendBufferReference(_sem == 0 ? _buffer0 : _buffer1, buffer, 0, 0, 0);
  //if(sampleBuffer)
  //    CFRelease(sampleBuffer);
  </code></pre>
  
  <p>Why does this cause a memory leak at the first line (at least that's where Leaks suggests)? I have my assetOutput.shouldAlwaysCopySampleOutput = NO. Here's my understanding of the situation:</p>
  
  <pre><code>CMSampleBufferRef sampleBuffer = [assetOutput copyNextSampleBuffer];
  </code></pre>
  
  <p>This line will create a <em>reference</em> to the sample buffer from the assetOutput.</p>
  
  <pre><code>CMBlockBufferRef buffer = CMSampleBufferGetDataBuffer(sampleBuffer);
  </code></pre>
  
  <p>This line will get the CMBlockBuffer from the CMSampleBuffer but will not allocate a new buffer, and the Get method in this case means it is a temporary (autoreleased) buffer</p>
  
  <pre><code>CMBlockBufferAppendBufferReference(_sem == 0 ? _buffer0 : _buffer1, buffer, 0, 0, 0);
  </code></pre>
  
  <p>This line will append the <em>reference</em> of the CMBlockBuffer created above, to the selected global-scope buffer. It will not copy any memory blocks.</p>
  
  <p>So in none of these three lines do I allocate any memory nor do I copy any memory, it's all references. I don't understand where the leak is coming from. I tried adding the commented out lines and it still seems to leak (although fewer times)</p>