title: Objective C memory leak problem
body: <p>I have the memory leak problem in the following objective c code. The <s>bold</s>asterisked(<code>***</code>) line is the line with memory leak (mentioned in instrument).  Any idea of it?  Thanks.</p>
  
  <pre><code>- (UIImage*)part:(float)part ofImage:(UIImage*)imgObject withMask:(UIImage*)imgMask {
   UIImage *imgResult = nil;
   CGRect rcMask = CGRectMake(0.0f, 0.0f, imgMask.size.width, imgMask.size.height);
   CGRect rcObject = CGRectMake(0.5f * (rcMask.size.width - imgObject.size.width), 0.0f, imgObject.size.width, imgObject.size.height * part);
  
   BytePtr pictureData = (BytePtr)malloc(rcMask.size.width * rcMask.size.height * 4);
   CGContextRef pictureContext = CGBitmapContextCreate(pictureData, rcMask.size.width,              rcMask.size.height,8, rcMask.size.width * 4,CGImageGetColorSpace(imgObject.CGImage),              kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
  
   CGContextClipToMask(pictureContext, rcMask, imgMask.CGImage);
   CGImageRef imgInRect;
   imgInRect = CGImageCreateWithImageInRect(imgObject.CGImage, rcObject);
   CGContextDrawImage(pictureContext, rcObject, imgInRect);
   CGImageRelease(imgInRect);
   ***imgResult = [UIImage imageWithCGImage:CGBitmapContextCreateImage(pictureContext)];***
  
   CGContextRelease(pictureContext);
   free(pictureData);
   return imgResult;
  }
  </code></pre>