未发布面部检测器的内存使用情况

时间:2013-09-12 09:49:54

标签: ios profiler nsautoreleasepool cifacefeature

我在这样的图像的所有可能方向上使用iOS人脸检测器

for (exif = 1; exif <= 8 ; exif++)
{
    @autoreleasepool {


    NSNumber *orientation = [NSNumber numberWithInt:exif];
    NSDictionary *imageOptions = [NSDictionary dictionaryWithObject:orientation forKey:CIDetectorImageOrientation];
    NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];

    glFlush();
    features = [self.detector featuresInImage:ciimage options:imageOptions];
    //features = [self.detector featuresInImage:ciimage];

    if (features.count > 0)
    {
        NSString *str = [NSString stringWithFormat:@"-I- found faces using exif %d",exif];
        [faceDetection log:str];
        NSTimeInterval duration = [NSDate timeIntervalSinceReferenceDate] - start;
        str = [NSString stringWithFormat:@"-I- facedetection total runtime is %f s",duration];
        [faceDetection log:str];
        self.exif=[[NSNumber alloc] initWithInt:exif];
        break;
    }
    else {
        features = nil;   
    }
    }

}

但是在分析器中似乎每次内存都在增长:

不确定这是否属实,如果是,如何解决问题

Sorted by overall bytes and still living

Detail of the category

The relevant code

1 个答案:

答案 0 :(得分:0)

在你的循环中,大多数对象都是自动释放类型,主要问题似乎是你在每个循环中为“features”分配新值,如果“if”语句为true,你就不会将其设为nil。试着这样做:

if(features.count > 0)
{
  /// your existing code here
  features = nil;
  break;

}