iPad 1 Memory Analysis
So I decided this weekend I’d take a really in depth look at the memory usage of my project on the iPad 1, and I found a number of very interesting facts. The problem is that switching from one section of my project to another required swapping out sprite sheets, and I was hitting a memory limitation only on the iPad1.
So the app starts, and the main menu uses about 10 MB of allocations. It’s very interactive, and has very pretty graphics. Switching to the store front, however, would cause a crash. The app would jump from 10 MB allocated to 28 MB allocated, and stabilizes at about 24 MB when the store shows up. Loading the store took just under two seconds including a programmatic 0.75 second fade animation. But what I found most interesting is how many memory flags were thrown just after the store appeared. I assume that this is because of the Main Menu assets staying allocated, and needing to be released. But the iPad 1 only appears to allocate 128 MB of Physical Memory Used portion shown above.
The first few times I tried running this, I couldn’t get my Physical Memory below 100 MB as a base for the amount used. After restarting, and triggering some memory flags, the iPad 1 was able to get down to 85 MB including 24 MB from the active application.
What I learned today is that the iPad 1 can and will crash an app that uses more than 28 MB allocated memory. I had previously assumed that it could handle up to 40 MB allocations (Bad practice, but if needed during a transition, or if you are too lazy, etc.) So a reminder to devs: Keep your allocations under 28 MB or so for iPad1. And a reminder to users: frequently restart your iPad 1 to get up to 60 MB of memory freed up for applications.
I learned a number of other things as well about the iPad 1 hardware, but these are probably more superflous to this post. As a last note, be sure that you don’t load more than 3-4 1024×1024 sprite sheets at once for the iPad1. Technically it’ll support a 2048×2048 atlas, but that just about fills the memory limit.