• Thanks for the Memory

    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:

    [caption id="attachment_58" align="aligncenter" width="300"]First Generation iPad First Generation iPad (iOS 5.1.1) [/caption][caption id="attachment_59" align="aligncenter" width="300"]Second Generation iPad (iOS 6.1.3) Second Generation iPad (iOS 6.1.3)[/caption][caption id="attachment_93" align="aligncenter" width="300"]iPad 3 iPad 3 (iOS 6.1.3) [/caption][caption id="attachment_61" align="aligncenter" width="300"]iPad Mini (iOS 6.1.3) iPad Mini (iOS 6.1.3)[/caption]

    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.

    * iOS 5.1.1 on the iPad 1 and iOS 6.3.1 on the other devices
    ** The 2nd gen iPad appears to be able to go as high as 295MB
    *** The iPad Mini appears to be able to go as high as 315 MB
  • A Retrospective of the Beginning

    I was recently trolling through some of my previous attempts at regular blogging and I found a post that I wrote back in September of 2008.  It was not all that long ago and yet it seems like a lifetime ago in terms of how my life has changed. At the time, I was still working on the Corporate Ladder, had just finished my MBA and hadn’t really written code for a number of years.

    The technology world was also different.  The iPhone had been out for a little over a year and people knew it was a big deal, but the App Store had only been a thing for a couple of months and the entire universe of Apps had yet to explode. My how things have changed.

    At the time of the post I was having serious creative withdrawals from not having written code for a long time. So I did what I always do: I started making things that I wanted to use personally, or in this case that I wanted my kids to use.  Little did I know that after having spent so long away from a compiler I was about to unleash a series of changes that would change my path in wonderful and unforeseen ways. I continued to mess around with Blackberry development for a few more weeks until I eventually downloaded Xcode one fateful day in October.  I started making little things for the Simulator and shortly after that, Three Jacks was born.

    I stayed at my corporate job for a few more years, but my weekends and evenings were consumed with making and releasing Apps for the iPhone (and eventually iPad.) Eventually, I was forced to come to the realization that while I was a good engineering leader, I could no longer deny the fact that my real passion was in making things and in creating code, so I finally clicked my heels three times and returned to full time development.

    Returning to the developer life also had a beneficial side effect that I could now work from home. This opened up an incredible freedom that allowed changes in my personal life that wouldn’t have been possible otherwise.  These were good things. I now have the flexibility to help coach my son’s Lego Robotics team. I know that I will never have to miss my daughter’s basketball games. I can walk the kids to school in the morning and I’m there when they get home. If they need help with homework, I’m there to lend a hand. If I want to take a break and build with Legos with Brendan, I can. These are moments and times that will be gone all too soon and because I started tinkering with Apps back in September 2008 I get to experience and savor them.

    Until reading it the other night, I had completely forgotten about tinkering on my old Blackberry. The existence of this five year old blog post is an amazing gift to me. It’s not often that you can look back at events in your life and pinpoint a single turning point where your path diverted from the course it had been on.

  • Reboot

    Image

    So this is the requisite "I used to blog and then I stopped but this time I'm serious about it" post. Like many people I have followed a pattern of ups and downs in terms of blogging continuity throughout my online existence, and it is my sincere intent to break the cycle this time around.  In particuar, Manton's post combined with Matt Gemmell's article have rekindled a desire to be better about developing and sustaining a rhythm.  I certainly have plenty of ideas, and it really is only my own lack of discipline that gets in the way. Anyway, I won't blather here longer about new beginnings but if you don't see regular output here, feel free to remind me of what I'm saying here.

subscribe via RSS