title: Objective C- Memory leak with CGDataProviderCopyData
body: <p>Im new developer on ObjC and trying to make a fill color app. When I touch on a image, the color will be changed but I got the merory leak with this function need your help:</p>
  
  <pre><code>-(void) updateImageWithColorSelected:(int) pos{
     CGImageRef imageRef = self.basicImage.CGImage;
     NSData *data = CGDataProviderCopyData(CGImagerGetDataProvider(imageRef));//leak here
     Byte *pixels = (Byte *)[data bytes];
     //change color...
     for(int i = 0; i&lt; IMG_SIZE; i++){
       pixels[j] = 255;
     }
     CGDataProvider provider = CGDataProviderCreateWithData( NULL, pixels, [data length], NULL];
     CGImageRef newImageRef = CGImageCreate(w,h....);
     self.basicImage = [UIImage imageWithCGImage:newImageRef];
     //release newImageRef
     CGImagerRelease(newImageRef);
  
     // set basic image to img
     [self.img setImage:self.basicImage];
  
     data = nil;
     [data release];
  }
  </code></pre>
  
  <p>I try to remove all the code except NSData *data = CGDataProviderCopyData and the app still leak.
  Do you guys have any idea how to release "data" ?</p>
  
  <p>Thank you in advance,</p>
  
  <p>}</p>