I am analyzing this block of code from the SDK and basing the error type on the answer to my last question:
How to free memory in iOS: memory is never released; potential memory leak indicated by
dasblinkenlight suggested that I create an NSData object in order to release my uint8_t * bytes ...
But here in this code:
-(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 error on these lines:
potential leak of an object stored in "myColorspace"
CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, num_locations);
potential leak of an object stored in "myGradient"
UIGraphicsPopContext();
I tried:
free(myColorspace); free(myGradient);
but I keep the same problems that I can do to solve it
Thank you in advance for your support.