title: Necessary to release CGGradientCreateWithColorComponents?
body: <p>I have custom <code>UIView</code> drawing in <code>drawRect</code>.</p>
  
  <p>I don't know the C APIs that well so I'm not sure what memory rules they require. The Objective-C rules are pretty simple and state that you release anything you own via <code>init</code> <code>retain</code> or <code>copy</code> but the C function <code>CGGradientCreateWithColorComponents</code> is not Objective-C and the Product > Analyze reports that it is a potential leak.</p>
  
  <p>Is it necessary to release the results of this function, and if so, how? And in general, when it comes to these APIs, is there any easy way to know if a function is allocating memory that you need to manually release?</p>
  
  <p>UPDATE: Here is the code, thanks to the information in the answers so far. I'm getting <code>incorrect decrement</code> error now:</p>
  
  <pre><code>CGGradientRef theGradient=[self makeGradient:YES];
  //do something with theGradient in my drawing
  CGGradientRelease(theGradient); // this line Analyze says incorrect decrement of object not owned by caller
  </code></pre>
  
  <p>And in <code>makeGradient</code> I have:</p>
  
  <pre><code> - (CGGradientRef)makeGradient:(BOOL)red{
       CGGradientRef gradient;
       //create my gradient
       return gradient;
   }
  </code></pre>