So I have been scratching my head of the past few days trying to patch a memory leak while trying to blur an image using the core image. I have traced the memory leakage down to this block of code:
- (void) blurImage {
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"Captured Image");
@autoreleasepool {
CIImage *inputImage = [[CIImage alloc] initWithCGImage:image.CGImage];
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setValue:inputImage forKey:@"inputImage"];
[filter setValue:[NSNumber numberWithFloat:10.0] forKey:@"inputRadius"];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
blur_image.image= [[UIImage alloc] initWithCIImage:result];
}
NSLog(@"blurred Image");
}
This code does two things, it first captures a screen shot of the screen at the time, then it blurs that image and sets it int to an image view in the background of my superview.
I am calling this block of code using a selector to run in the background
- (void) viewDidAppear:(BOOL)animated{
SEL blur = @selector(blurImage);
[self performSelectorInBackground:blur withObject:nil];
}
I am getting a 3 memory leaks that is associated with this code
This is the leakage I mentioned: CoreImage CI::GLESContext::program_for_name(__CFString const*)
I am befuddled as to what i am doing wrong can someone enlighten me?