我正在分析来自 SDK 的这段代码,并将错误类型基于我最新问题的答案:
dasblinkenlight 建议我创建一个 NSData 对象,以便释放我的 uint8_t *bytes ...
但在这段代码中:
/**
* this will set the brush texture for this view
* by generating a default UIImage. the image is a
* 20px radius circle with a feathered edge
*/
-(void) createDefaultBrushTexture{
UIGraphicsBeginImageContext(CGSizeMake(64, 64));
CGContextRef defBrushTextureContext = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(defBrushTextureContext);
size_t num_locations = 3;
CGFloat locations[3] = { 0.0, 0.8, 1.0 };
CGFloat components[12] = { 1.0,1.0,1.0, 1.0,
1.0,1.0,1.0, 1.0,
1.0,1.0,1.0, 0.0 };
CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, num_locations);
CGPoint myCentrePoint = CGPointMake(32, 32);
float myRadius = 20;
CGContextDrawRadialGradient (UIGraphicsGetCurrentContext(), myGradient, myCentrePoint,
0, myCentrePoint, myRadius,
kCGGradientDrawsAfterEndLocation);
UIGraphicsPopContext();
[self setBrushTexture:UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext();
}
我在这些行上遇到了同样的错误:
存储到“myColorspace”中的对象的潜在泄漏
CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, num_locations);
存储到“myGradient”中的对象的潜在泄漏
UIGraphicsPopContext();
我试过:
free(myColorspace);
free(myGradient);
但我一直有同样的问题,我能做些什么来解决它
预先感谢您的所有支持