I've been developing an app which is live on the app store but some users have been complaining of crashing (especially on older devices) I have thoroughly checked the app using the leaks instrument and there are no memory leaks. I have also removed all 'autoreleases' where possible.
When I run the app on the 3G I still get memory warnings and after a few minutes the app usually crashes.
Anyone have any idea if I have missed anything?
__________________ Mathster - Maths brain training with a twist! SoundZen - Generative sound sequencer using cellular logic
There may be no leaks but you could be using too much memory considering an older device. Use Instruments to see just how much and where you allocate memory and see if you can make some optimizations. Follow the general guideline for loading resources lazily, that is, only when you just need them and don't keep them cached.
We do have a gallery section where we load in some pretty big images but while there is usually a warning here, it's mainly on sections with much smaller images. I do cache the last 10 images but I regularly purge older images and I purge all of them after a memory warning.
Thanks for the help guys, is there anything else that could cause this?
Thanks for the advice baja_yu - I will check it out with instruments now
__________________ Mathster - Maths brain training with a twist! SoundZen - Generative sound sequencer using cellular logic
so most probably are the images, maybe are you using autoresized images, but with an high res? how many image you load together? and which resolution they have?
We do have a gallery section where we load in some pretty big images but while there is usually a warning here, it's mainly on sections with much smaller images. I do cache the last 10 images but I regularly purge older images and I purge all of them after a memory warning.
Thanks for the help guys, is there anything else that could cause this?
Thanks for the advice baja_yu - I will check it out with instruments now
iOS devices are memory-starved. The older the device, the worse it is. The original iPhone is the worst in terms of limited memory. I don't remember the amounts off the top of my head, but the limits are kinda scary. The 3Gs is a lot better, and the iPhone 4 is better still.
You need to write you app to handle low memory warnings and release memory when they get called. If you download images from a server, you can save them to local files. Write your code to check to see if your image pointer is nil before using the image, and reload it from a file if it is. Then write your low memory warning code to release everything it possibly can and set the released object's pointers to nil.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
There was a great presentation in the last years WWDC where the presenter was talking about the PhotoScroller (I think) sample code. It mimics some of the functionality of the Photos app, where you have multiple images that you can zoom in/out and scroll through them. One part of the talk was about memory management. The point was, that if it's a very big image, they use several images of it when working with it, several scaled down versions. If you stretch a huge image down to 100x100 for example on screen, in the background iOS will still be using the huge image and it will have an adverse effect on memory and processing. They instead use several different images and switch them dynamically as you zoom in to provide you with a high res image.
Thanks for your help guys, looks like it's definitely a problem due to the iPhone 3G's low memory - I will try all your tips for lowering my use of it
Thanks!
Probably you will be OK if you handle the memory warnings properly. I get a lot of such warnings in one of my apps, but then the app removes all the currently non-crucial data and all is fine. It's never crashed because of a memory error.
It's crucial too that you have dealloc set up to properly dispose of those UIViews that the system will trash on its own - in particular if IBOutlets are not set to nil there, a crash can occur when the view is reloaded.