Severe memory problems with UIImagePickerControlle

2019-08-03 09:10发布

I've noticed that when I load a UIImagePickerController and I take a picture with it, didReceiveMemoryWarning is called. Also, in Instruments, there is a significant memory leak (not by me, I swear!). I've heard that this is a problem with UIImagePickerController but, I'm not sure how to fix it. Here is my implementation of UIImagePickerController.

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; // Create the imagePicker
    imagePicker.delegate = self; 
    imagePicker.allowsEditing = YES; // Allow editing of the images
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController:imagePicker animated:YES];
    [imagePicker release];

Any ideas? I really don't want to sacrifice such a useful feature.

2条回答
狗以群分
2楼-- · 2019-08-03 09:52

Do you have the same leak with the SDK 3.2?
I had a similar leak when using the UIImagePickerController to take a video.

When I found that the leak was fixed in 3.2, I decided to set the minimum OS version of my application to 3.2.

About the memory warning, it's to be expected. The camera needs a lot of memory to do its job, and is simply requesting as much memory as possible from your app by sending a didReceiveMemoryWarning message.

查看更多
太酷不给撩
3楼-- · 2019-08-03 10:07

You need to rescale the image to a smaller size, say 320x460. Then it will run successfully.

查看更多
登录 后发表回答