O'Reilly logo

Cocoa Programming for Mac OS X, Third Edition by Aaron Hillegass

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

Chapter 4. Memory Management

Let’s say that there are two instances of Person and that each has a favoriteColor, a pointer to a color object. If two people have the same favoriteColor, the objects will have pointers to the same color object. As the people age, their favorite color might change. Eventually, the color object might be no one’s favorite (Figure 4.1).

The Problem

Figure 4.1. The Problem

We do not want this orphaned color to be taking up room in our program’s memory. We want the memory deallocated, so that we can put new objects in that memory, but we must be sure that the color is not deallocated while any objects are pointing to it.

This is a relatively ...

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