我昨天开始了一个项目,看看不同的CIFilters是如何工作的。我已经完成了所有工作,但我注意到每次使用新过滤器时我的应用程序内存都会出现问题。直到现在我已经看到记忆力达到了80mb ......对于像我试图做的那样简单的事情来说太过分了......我必须有一些物品。分配,但他们没有被解除分配。我正在使用带有xCode 5.1.1
的ARC应用程序这是代码
-(UIImage *)filteredImageFromImage:(UIImage *)image andFilter:(CIFilter *)filter
{
/* Create a CIImage using the property on UIImage, CGImage. */
CIImage *unfilteredImage = [[CIImage alloc] initWithCGImage:image.CGImage];
/* Set the filter with the unfiltered CIImage for key kCIInputImageKey */
[filter setValue:unfilteredImage forKey:kCIInputImageKey];
/* Get the filtered image back calling the method outputImage */
CIImage *filteredImage = [filter outputImage];
return [UIImage imageWithCIImage:filteredImage];
}
- (CIFilter *)filterAtIndex:(int)index
{
CIFilter *filter = nil;
switch (index) {
case 0: // Blur
filter = [CIFilter filterWithName:@"CIGaussianBlur" keysAndValues: nil];
break;
case 1: // Sepia
filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:nil];
break;
case 2: // Monochrome
filter = [CIFilter filterWithName:@"CIColorMonochrome" keysAndValues: nil];
break;
case 3: // Color Invert
filter = [CIFilter filterWithName:@"CIColorInvert" keysAndValues:nil];
break;
case 4: // False Color
filter = [CIFilter filterWithName:@"CIFalseColor" keysAndValues: nil];
break;
case 5: // Posterize
filter = [CIFilter filterWithName:@"CIColorPosterize" keysAndValues:nil];
break;
default:
break;
}
return filter;
}
这不是我的代码......我从网上挑选了......做了一些改动......但是我已经搜索了很多但找不到原版...
任何人都可以帮我弄清楚为什么这段代码会产生很多未释放的内存。
提前致谢...