Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory warning after using the UIImagePicker once

I've referred to this very good reference: https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more but I'm having some very serious issues. After I take a photo, I receive a memory warning. This is for the first photo I take, not the second or third.

I was wondering if it's because I've got a couple of small jpegs loaded from the application directory into scrolling views. The only solution I can think of is to unload everything in my mainview whilst the UIImagePicker is active, and reload everything again afterwards, but I'm not sure that's the correct solution and I'm not sure how to do that.

Does the UIImagePicker use up that much memory? I haven't even got as far as processing or displaying the image it takes yet. I get a memory warning, even if I throw the image away.

Any help appreciated.

like image 695
mac_55 Avatar asked Dec 02 '09 16:12

mac_55


1 Answers

For all the people that are still looking for the actual answer and not a vague statement then look here. I noticed there are hundreds of answers such as "Handle your memory" but that doesn't answer anything. Hope this helps someone else out there...

Change the following

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [imageView setImage:image];
    [self dismissModalViewControllerAnimated:YES];
}

To the following so your modal view dismisses before setting your image...

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [self dismissModalViewControllerAnimated:YES];
    [imageView setImage:image];
}
like image 197
Mark McCorkle Avatar answered Nov 15 '22 05:11

Mark McCorkle