Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 使用核心图像过滤器时的数据内存使用率_Iphone_Automatic Ref Counting_Dealloc_Core Image_Cfdata - Fatal编程技术网

Iphone 使用核心图像过滤器时的数据内存使用率

Iphone 使用核心图像过滤器时的数据内存使用率,iphone,automatic-ref-counting,dealloc,core-image,cfdata,Iphone,Automatic Ref Counting,Dealloc,Core Image,Cfdata,我的内存分配太多了。我的应用程序alloc mem高达100MB! 是的。。。我正在使用ARC。大部分内存是通过CFData分配的(据我所知,它是CoreImage过滤器)。对图像应用过滤器后,CFData分配的内存增加约1.3mb,并且不会取消分配: 代码如下所示: +(UIImage*)BWFilter:(UIImage *)imgFX { CIImage *sourceImage = [[CIImage alloc] initWithImage:imgFX]; CIIm

我的内存分配太多了。我的应用程序alloc mem高达100MB! 是的。。。我正在使用
ARC
。大部分内存是通过
CFData
分配的(据我所知,它是
CoreImage
过滤器)。对图像应用过滤器后,
CFData
分配的内存增加约1.3mb,并且不会取消分配:

代码如下所示:

+(UIImage*)BWFilter:(UIImage *)imgFX
{
    CIImage *sourceImage = [[CIImage alloc] initWithImage:imgFX];

    CIImage *blackAndWhite = [CIFilter filterWithName:@"CIColorControls" keysAndValues:kCIInputImageKey, sourceImage, @"inputBrightness", [NSNumber numberWithFloat:0.0], @"inputContrast", [NSNumber numberWithFloat:1.1], @"inputSaturation", [NSNumber numberWithFloat:0.0], nil].outputImage;
    CIImage *output = [CIFilter filterWithName:@"CIExposureAdjust" keysAndValues:kCIInputImageKey, blackAndWhite, @"inputEV", [NSNumber numberWithFloat:0.7], nil].outputImage;

    CIContext *context = [CIContext contextWithOptions:nil];
    CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent];
    imgFX = [UIImage imageWithCGImage:cgiimage];

    if (cgiimage) {
        CGImageRelease(cgiimage);
    }

    return imgFX;
}

内存警告后,内存使用率不会下降,因此不应该是缓存问题。

我在一个示例项目(使用ARC)上运行了您的代码,它不会提供任何泄漏或额外分配
CFData
基本上与
CIFilter
子类无关,而是与
CIImage
相关。问题出在其他地方。

如何存储返回的图像?或者,换句话说,调用代码是什么样子的?问题中的代码示例看起来不错。还有,泄漏仪器怎么说?你运行静态分析仪了吗?产品>分析。它能给你们诊断吗?静态分析仪什么都不给。和泄漏仪器没有显示任何泄漏。我调用ReDraw方法来重画列表中存储的所有过滤器;第一次应用筛选器后不工作,因为它不会释放由cgimg=[context createCGImage:outputImage fromRect:[outputImage extent]]创建的图像;