Memory Usage in UIImagePickerController
I’m diligently working on app #2, which includes the ability to use photos from your photo library (or the camera if your device has one) and I ran into some memory issues. If you repeatedly create and destroy UIImagePickerController instances, you’ll quickly run out of memory (after picking like, seven photos). Fortunately, a little digging around led to the solution. Essentially, it involves keeping one instance around and continually re-using it.
Oh, also, if you’re doing animation in your app, be sure to turn off the animation while you access the camera. Otherwise, the camera will be really, really slow; causing you to question whether or not your app idea is even feasible; leading to a looong sleepless night until you finally realize what you were doing wrong. Just sayin’…
I make mistakes so that you don’t have to.
January 23rd, 2009 at 10:20 am
Nice. Thanks for tips Mach!
October 29th, 2009 at 10:25 pm
Aha…! Nice. Thank you very much for these tips!
October 30th, 2009 at 7:18 am
Glad to be of service! =)
January 13th, 2010 at 10:53 pm
Hello,
Thanks for the tutorial. I am using UIImagePickerController from one of my application and facing very strange problem. When i select an image from library and display it in imageview the memory consumption become very high (from 2.5MB to 12.9 MB, incase i select heavy image) and never came down again. If i comment the line which display the image in imageview the memory does not rise up at all. Can you please help me on this as i m really struck on this issue.
What i exactly do when selected image from imagepicker controller i saved it in application delegate UIimage type variable and then display it using setimage.
Thanks
Tarun sharma
January 14th, 2010 at 9:19 am
I don’t know what the problem is as I’ve got a similar issue with Holograms but I’m guessing that somehow the image getting set gets retained an extra time.