巨大的内存泄漏UIImagePickerController

时间:2012-12-15 01:42:24

标签: ios6 uiimagepickercontroller

我见过其他线索,但我看起来更具戏剧性。我正在使用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的活动内存。当我点击取消以关闭视图时,内存保持在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
    }];
}

0 个答案:

没有答案