Observing Low-Memory Warnings
Even if you’ve done everything correctly, in a large application you may simply run out of memory. When that situation occurs, the system dispatches a low-memory notification to your application — and it’s something you must pay attention to. If you don’t, it’s a reliable recipe for disaster. (Think of your low-fuel light going on as you approach a sign on the highway that says, “Next services 100 miles.”) UIKit
provides several ways for you to set up your application so that you receive timely low-memory notifications:
Override the viewDidUnload
and didReceiveMemoryWarning
methods in your custom UIViewController
subclass.
Implement the applicationDidReceiveMemoryWarning:
method of your application delegate.
Register to receive the UIApplicationDidReceiveMemoryWarning Notification:
notification.
The viewDidUnload method
When a low-memory condition occurs, one way to free some memory is to remove views that aren’t being used. You don’t have to worry about that, however, because it’s handled in the view controller class from which you derive your view controllers — UIViewController
.
What you do have to worry about, though, is managing any references to ...
Get iPad Application Development For Dummies, 3rd Edition 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.