Ios6 ImagePickerController存在巨大内存泄漏

Ios6 ImagePickerController存在巨大内存泄漏,ios6,uiimagepickercontroller,Ios6,Uiimagepickercontroller,我见过其他的线索,但我的似乎更戏剧性。我使用UIImagePickerController允许用户选择或拍摄自己的照片 下面是一些代码: if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO)) return NO; ImagePickingViewController *cameraUI = [Image

我见过其他的线索,但我的似乎更戏剧性。我使用UIImagePickerController允许用户选择或拍摄自己的照片

下面是一些代码:

if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeCamera] == NO))
        return NO;

    ImagePickingViewController *cameraUI = [ImagePickingViewController sharedImagePickingController];
    cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    cameraUI.allowsEditing = NO;

    cameraUI.delegate = self;

    [self presentViewController:cameraUI animated:YES completion:^{
        //do nothing
    }];
一旦执行此操作,我的内存分配将从~3MB变为6MB的活动内存。当我点击cancel关闭视图时,内存保持在6MB!!如果我选择一个图像,它会变得更高,并且多次崩溃

有什么想法吗

我运行的是iOS 6,没有使用ARC

[编辑]:这是没有我的类包装器的代码。它也会做同样的事情——在显示视图时泄漏3MB内存,即使在视图关闭后也不会返回

if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeCamera] == NO))
        return NO;

    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    cameraUI.allowsEditing = NO;

    cameraUI.delegate = self;

    [self presentViewController:cameraUI animated:YES completion:^{
        //do nothing
    }];
下面是委托方法

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSLog(@"Image picker finished picking.");
    [self.navigationController dismissViewControllerAnimated:NO completion:^{
        //do nothing
    }];
    [self dismissViewControllerAnimated:NO completion:^{
        //do nothing
    }];

    UIImage *originalImage = (UIImage *)[info objectForKey:
                                    UIImagePickerControllerOriginalImage];
        //Do stuff with image
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [loadingViewController.view removeFromSuperview];
    [self dismissViewControllerAnimated:YES completion:^{
        //Do stuff
    }];
}

但是在这个故事中没有UIImagePickerController,那么你为什么要把责任推到那里呢?问题是什么是
ImagePickingViewController
?我们无法知道这是什么。所有人都知道,这就是内存问题的开始。你的代码没有理由相信苹果的UIImagePickerController类有问题,或者它甚至有问题。对不起,我不清楚。ImagePickingViewController只是UIImagePickerController上作为单例的空包装器。当视图被按下(使用分配/泄漏检查器)时,我看到一个3MB内存跳转,并且它永远不会返回。我也尝试过直接分配/释放UIImagePickerController,并由于对SO的评论而切换到singleton,但这并没有解决问题,因此我的post.UIImagePickerController不是singleton。使用它的规则很明确。它是一个视图控制器。您不需要分配单例视图控制器!它正在管理一个视图。它需要以良好的顺序出现和消失。你实例化它,呈现它,抛弃它,让它释放。只需按预期使用UIImagePickerController。否则就是你的记忆管理不好好好吧。。。不管是哪种方式,我都说它做同样的事情,不管它是不是单身。我已经编辑了我的帖子,向你展示了代码。你能帮我一下吗?那很好,但是你的新代码对我来说毫无意义。在
中,您是否忽略了两件事?在
didconcel:
中,为什么手动干扰视图控制器的视图?这里还有很多事情要做,而“更多”可能是你困难的根源。我有两条建议:(1)在视图控制器方面行为正确、干净,(2)如果您认为内存有问题,不要猜测-使用仪器测量并跟踪它们。