In my game I’m grabbing an image from the iPhone’s photo library using the UIImagePickerController, which returns a UIImage. Because the image is a huge resolution (1536×2048), this UIImage takes up almost 20mb in memory. To resolve this, I shrink the image significantly before using it to generate a sprite and this works in reducing the memory footprint. However, there is a brief moment before the image is resized that my memory usage spikes really high, and I’m worried this could cause crashes in low memory situations (although I don’t get any low memory warnings). Anyone have any ideas on how to deal with this scenario?
Thanks!
I can confirm exactly what you’re saying: UIImagePicker is, for a fairly brief moment of its lifetime, a massive RAM hog.
All I can tell you is to clear as much memory as you can on your way in. I managed to minimize crashing by ditching every other image I have in memory and loading it back in after I catch and resize the UIImage I’m returned from the Picker.
The only REAL solution I found was to get myself an iPhone 4. It has enough memory to cope. My poor old 3G was very easy to crush with UIImagePicker.