title: Memory leak in CGImage
body: <p>I've got a memory leak i just don't know how to solve.</p>
  
  <p>This is the leaking code:</p>
  
  <pre><code>[newImg release];
  CGColorSpaceRef d_colorSpace = CGColorSpaceCreateDeviceRGB();
  CGContextRef context =  CGBitmapContextCreate(Data, width, 
                                                height, 
                                                8, 4*width, 
                                                d_colorSpace, 
                                                kCGImageAlphaNoneSkipFirst);
  UIGraphicsPushContext(context);
  CGImageRef new_img = CGBitmapContextCreateImage(context);
  UIImage * convertedImage = [[UIImage alloc] initWithCGImage:
                               new_img];
  CGImageRelease(new_img);
  CGContextRelease(context);
  CGColorSpaceRelease(d_colorSpace);
  newImg = convertedImage;
  </code></pre>
  
  <p>I modify pixel information stored in Data, then with this method i create a UIImage back from the Data (which is as unsigned char array)</p>
  
  <p>The xcode instruments tells me that there are leaks in here:</p>
  
  <pre><code>CGImageRef new_img = CGBitmapContextCreateImage(context);
  </code></pre>
  
  <p>And here:</p>
  
  <pre><code>UIImage * convertedImage = [[UIImage alloc] initWithCGImage:
                               new_img];
  </code></pre>
  
  <p>though i release both of them :( Can somebody tell me how to solve this?</p>
  
  <p>Thanks in advance ^-^</p>