O'Reilly logo

iPad Application Development For Dummies, 3rd Edition by Neal Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

check.png Override the viewDidUnload and didReceiveMemoryWarning methods in your custom UIViewController subclass.

check.png Implement the applicationDidReceiveMemoryWarning: method of your application delegate.

check.png 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required