返されるコードの最後の 2 行は、潜在的なメモリ リークの警告を示しています。.....これは真陽性の警告ですか、それとも偽陽性の警告ですか? 本当の場合、どうすれば修正できますか? 助けてくれてどうもありがとう!
-(UIImage*)setMenuImage:(UIImage*)inImage isColor:(Boolean)bColor
{
int w = inImage.size.width + (_borderDeep * 2);
int h = inImage.size.height + (_borderDeep * 2);
CGColorSpaceRef colorSpace;
CGContextRef context;
if (YES == bColor)
{
colorSpace = CGColorSpaceCreateDeviceRGB();
context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
}
else
{
colorSpace = CGColorSpaceCreateDeviceGray();
context = CGBitmapContextCreate(NULL, w, h, 8, w, colorSpace, kCGImageAlphaNone);
}
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextDrawImage(context, CGRectMake(_borderDeep, _borderDeep, inImage.size.width, inImage.size.height), inImage.CGImage);
CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context); //releasing context
CGColorSpaceRelease(colorSpace); //releasing colorSpace
//// The two lines of code above caused Analyzer gives me a warning of potential leak.....Is this a true positive warning or false positive warning? If true, how do i fix it?
return [UIImage imageWithCGImage:image];
}