在Objective-C中处理图像时发生内存泄漏

时间:2019-04-08 06:49:09

标签: ios objective-c image memory-management memory-leaks

我正在使用以下方法处理图像,第一行出现内存泄漏。该代码不是ARC,因此我必须手动释放内存。如何释放以下函数第一行中泄漏的内存?

-(UIImage*) manipulateImage :(UIImage *)image :(int)intType
{

    CIImage* inputImage = [[[CIImage alloc] initWithImage:image] autorelease]; //leak is here.
    CIFilter* filter = [CIFilter filterWithName:@"CIColorControls"];
    [filter setValue:inputImage forKey:kCIInputImageKey];

    [filter setValue:@(intType) forKey:kCIInputSaturationKey];

    CIImage* result = [filter valueForKey:kCIOutputImageKey];
    CIImage* returnImage = [result imageByCroppingToRect:[result extent]];
    return [[[UIImage alloc] initWithCGImage:returnImage.CGImage] autorelease];
}

0 个答案:

没有答案