In building Stickyboard and Quarter Shuffle, we’ve had to work very hard to optimize dynamic memory (RAM) usage on the iPad. Dynamic memory is not the same as storage memory (i.e. the 16GB, 32GB, 64GB of flash ram), which is analogous to hard drive storage on your laptop computer. All versions of the iPad contain only 256MB of dynamic memory, the same as the iPhone 3GS (the iPhone 3G only has half as much). In comparison, a typical laptop computer has 8 or 16 times that amount of RAM.
Actually, it’s worse than that. The base operating system on the iPad takes up over 100MB of that memory, which leaves around 150MB for services and Apps.
What makes things interesting is that certain built-in apps, namely Safari, Mail, and iTunes, actually run in the background and take up memory even when not active! Here’s a snapshot of one of our test iPad’s memory usage (using the Instruments tool):
Here, those 3 apps take up another 50MB of memory. After subtracting out all the other miscellaneous services (e.g. Bluetooth, DRM, location services, etc.), Apps are only left with around 50MB of memory to use. If an App ever tries to allocate more memory than what is available, it crashes, usually without warning.
The problem is that because background memory usage can vary quite a bit, it’s very hard for App Developers to predict what a safe maximum available memory is. For instance, you can see above that Stickyboard is taking up around 27MB of memory as a baseline. However, this can spike when loading boards, drawing lines, etc. In our testing, we’ve made sure not to exceed around 40MB of memory to leave a safe buffer. But if someone were to have a lot of tabs and complex pages open in Safari, or a large email active, available memory could possibly be lower than what is expected.
Tip: If you ever find your Apps frequently crashing on your iPad, try doing a hard reset. Hold down the Home and Power buttons down simultaneously for around 15 seconds until you see the Apple logo. This should reset background Apps enough to free the maximum RAM available.
While we haven’t done any testing on Jailbroken iPads, we know that one of the top features is the ability to run apps in the background. This is going to dramatically reduce available memory for the foreground app! If you are running J/B, be careful about monitoring available memory. While we wish running any app in the background were possible today, it’s pretty clear that the planned multitasking services in iPhone OS 4 are the right way to deal with the very limited memory on the iPad and iPhone.
Let’s hope that the next version of the iPhone and iPad come with much more dynamic memory. Especially if the rumors about higher resolution screens and cameras are true, this will almost certainly require double or quadruple the RAM needed, just in order to deal with higher resolution images.