views:

464

answers:

2

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.

A: 

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.

Guillaume
I haven't tried on 3.2, I will now, but when it asks for that much memory it removes data from the view below it which I don't really like.
Yakattak
Yeah, tried it on the 3.2 SDK, however, I obviously can't try it on iDevice OS 3.2, because that's not out for iPhone yet...
Yakattak
Odd... it just stopped all of the sudden. Oh well...
Yakattak
A: 

Ya here u need to rescale the image to smaller size say 320x460 and it will run successfully....

mrugen