I'm analyzing this block of code from an SDK and basing the kind of error on the answer of my latest question:
How to release correctly memory in iOS: Memory is never released; potential leak of memory pointed to by
dasblinkenlight suggested me to create an NSData object for could releasing my uint8_t *bytes...
But here in this code:
/**
* 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();
}
I got the same kind of error on these lines:
potential leak of an object stored into 'myColorspace'
CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, num_locations);
potential leak of an object stored into 'myGradient'
UIGraphicsPopContext();
I tried with:
free(myColorspace);
free(myGradient);
but I keep the same kind of issues, what can I do to resolve it
thanks in advance all your support