How much memory can an app allocate on an iPad 1? It seems like a trivial question. The original iPad has been in circulation for over 3 years now and developers have written thousands of apps, many of which are memory intensive. Given this, one would expect that this limit has been well documented and should show up easily in search results. As I found out recently, this is not the case.
A few weeks ago, I needed to revisit memory consumption on an app running on an iPad 1, and I became very curious about the answer to this question. After searching various sites I was mostly coming up empty. To my surprise, it was quite difficult to find this documented anywhere. Apple’s own documentation is of course great reading for any developer but remains mum on memory budgets. Perhaps the best documentation I could find was this Stack Overflow post, but it didn’t seem to be definitive and as with all Stack Overflow posts, caveat emptor.
One thing that I did find sprinkled around the various posts on the topic was a link to Jan Ilavsky’s tool that he wrote to measure on a device the various points when an app receives memory warnings and then ultimately crashes due to insufficient memory. Here’s a shot of it in action. Using Jan’s tool, I decided that perhaps I should help contribute to the collective information of the Internet by running some tests and documenting them.
So as not to boil the ocean, I decided to analyze only the iPad family of devices. My test devices included: a first generation iPad, a second generation iPad, a third generation iPad and an iPad Mini. All of the devices were upgraded to the latest version of iOS that supported them*. My procedure was to force quit all apps on the device before running the test app and then to run the test a minimum of 10 times on each device. I would then throw out the low and the high and graph the results. I found to be both interesting and somewhat predictable:
One of the more interesting things that jumped out at me is the fact that Apple seems to take memory optimization seriously, and that their approach appears to not be a one size fits all method for the different devices. Notice how on the second generation iPad and the iPad Mini the OS continues to optimize in order to allow the app more room in which to operate. Contrast that with the first and third generation iPads which appears to have a flat, non optimizing algorithm. If indeed memory optimization does have a certain amount of device specificity to it, it would appear that Apple put less time into optimizing these iPads.
This of course makes sense as the first iPad was a previously non-existant category, and the third generation was the first iPad with retina display. You have to imagine that it was a pretty massive undertaking to introduce the retina concept on an OS, toolchain and device level. I don’t think any engineer alive would be surprised if the schedule became tight on these projects. The point here however, is that Apple does indeed pay attention to the details and that permeates all the way down to device specific memory optimizations. Developers should of course never become reliant on the presence of these optimizing algorithms but the fact that Apple puts that much attention into it is impressive.
So, back to my original question of how much memory you can allocate on an iPad 1. Drumroll please. Based on my results, I would say that for the iPad family of devices the following are the maximum allocations that can be performed by an app:
First Generation iPad: 160 MB
Second Generation iPad: 250 MB**
Third Generation iPad: 515 MB
iPad Mini: 275 MB***
Now, I wouldn’t be doing my civic duty if I didn’t point out that these numbers include things that are entirely out of your control such as core graphics objects. The test application is the most plain vanilla of apps so the minute you start making anything interesting this number will begin to be impacted. In the end, there is simply no replacement for good old fashioned testing and optimizing so keep that in mind as you’re setting out to make the next Angry Birds. I do find this helpful however because it is useful to know and be aware of what my overall ceiling is so that I can spend time optimizing the things that need optimizing and spend the rest of the time building features.