Severe memory problems with UIImagePickerController using Camera

妖精的绣舞 提交于 2019-12-12 23:09:34

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/2264304/severe-memory-problems-with-uiimagepickercontroller-using-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!