Memory Management
This chapter has been hinting (not very subtly) at the need to pay attention to an iOS app’s memory usage. The emphasis on pointers in most of the frameworks is one of Apple’s contributions to help you be frugal with system resources.
An iOS device has a fixed amount of operating room in memory. This portion of memory is separate from the storage space reserved for music, video, and other files (where all the gigabytes of the device specifications lie).
Operating memory is measured in the hundreds of megabytes. The precise size is not important, except to say that not all devices are created equal in this respect. The iPhone 3GS, third-generation iPod touch, and first-generation iPad have twice as much memory available to apps than earlier models, while the iPhone 4 doubles even that amount. That’s why newer devices can accommodate the more memory-intensive features of iOS 4.0, such as multitasking, while older models cannot.
This stratification of available memory in devices also suggests that you should keep an older-model device on hand for testing when you get your app running on devices. A memory-hungry app that runs fine on an iPhone 4 can bring a second-generation iPod touch (a very popular model) to its knees. Also be aware that the simulator application does not simulate the constricted memory space of actual devices. Testing a developing app on real iOS devices is absolutely essential to spot critical memory issues and performance bottlenecks.
Cleaning Up ...
Get Learning the iOS 4 SDK for JavaScript Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.