views:

1427

answers:

2

Hi, I've referred to this very good reference: http://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.

A: 

Most likely you are using uneditted images, and they come back at full blown size of 1400x1300 which is huge and w ill crash your app, i suggest resizing the pictures to the iphone native 320x480 resolution, should fix your problem

Daniel
Hi, The images I'm displaying are far smaller than that, and I receive the memory warning after the camera takes the picture and before I have a chance to resize the image, so I'm not sure that this is the problem.
mac_55
yea it sounds that you might have other memory leaks somewhere t here
Daniel
so you take the picture and even before you can select it its c rashing?
Daniel
Yeah, I'm getting a warning before I press 'Use' and the the picker is hidden.
mac_55
+1  A: 

Yes, this happens. The thing to remember is that it's okay to get a memory warning, it doesn't mean you're a bad person, you just need to make sure that your application doesn't crash or get confused in response to the memory warning.

In particular, you need to understand that the default action of UIViewController is to unload its views if they're not visible, and they won't be visible if the full-screen image picker is showing.

David Maymudes
Right, so if I understand correctly, I don't need to hide my view whilst the UIImagePicker is displayed, as the view controller does that already, and that I'm allowed to get a memory warning after an image is taken.. so long as I'm not doing anything exotic (such as displaying a full resolution image?)
mac_55
if your app is using "too much" memory, and doesn't free "enough" of it when you get a low memory warning, the OS can potentially kill the app. there are no exact values as far as I know for "enough" and "too much".
David Maymudes
From this answer (http://stackoverflow.com/questions/457568/iphone-development-memory-limitation-for-iphone-application/457730#457730) it seems you get the warning at around 22MB of usage. Though Apple has not officially confirmed it.
Ben S