I am using the solution found here to blur an image with CIGaussianBlur. However, I am getting a memory leak that I cannot resolve. I originally was using not using CIContext as a property, but thought that could be the issue to no avail. I also was using a CGRect from the output image but changed this to try and close the leak, once again did not work.
I believe I am releasing all that I need to (ARC is on), so what could be causing the memory leak?
CIFilter *gaussianBlurFilter = [CIFilter filterWithName: @"CIGaussianBlur"];
CGImageRef cgimage = [image CGImage];
[gaussianBlurFilter setValue:[CIImage imageWithCGImage:cgimage] forKey:kCIInputImageKey];
[gaussianBlurFilter setValue:@10 forKey:kCIInputRadiusKey];
CIImage *outputImage = [gaussianBlurFilter outputImage];
if (imageContext == nil) {
imageContext = [CIContext contextWithOptions:nil];
}
CGImageRef cgimg = [imageContext createCGImage:outputImage fromRect:CGRectMake(0.0, 0.0, 25.0, 25.0)];
UIImage *blurredImage = [UIImage imageWithCGImage:cgimg];
pictureIncognito.image = blurredImage;
pictureIncognito.layer.cornerRadius = pictureIncognito.frame.size.width / 2.0;
pictureIncognito.layer.masksToBounds = YES;
pictureIncognito.layer.borderWidth = 1.0;
pictureIncognito.layer.borderColor = [[UIColor whiteColor] CGColor];
CGImageRelease(cgimage);
CGImageRelease(cgimg);