如果有人能告诉我原因,这段代码会泄漏?
UIGraphicsBeginImageContext(drawingImage.frame.size);
[drawingImage.image drawInRect:CGRectMake(0, 0, drawingImage.frame.size.width, drawingImage.frame.size.height)];
// Draw some vectorial data
// ...
// Apply an image mask
CGImageRef maskRef = mask.CGImage;
CGImageRef cgmask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef masked = CGImageCreateWithMask([UIGraphicsGetImageFromCurrentImageContext() CGImage], cgmask);
CGImageRelease(cgmask);
drawingImage.image = [UIImage imageWithCGImage:masked];
UIGraphicsEndImageContext();
答案 0 :(得分:4)
“蒙面”未发布,一旦您使用它创建图像,则需要将其释放
drawingImage.image = [UIImage imageWithCGImage:masked];
CGImageRelease(masked)