Introduction to Garbage Collection

In OS X, you can write programs that make use of an automatic memory management system commonly known as “garbage collection.” (Garbage collection is not available in iOS.) Garbage collection coexists with the traditional system of memory management (that uses manual reference counting using retain, release, and autorelease pools)—herein referred to as “manually reference counted”—and is hence an opt-in system.

These documents describe the complete garbage collection system provided for Cocoa, the functionality provided, and some of the issues that arise if you adopt this technology.

Who Should Read This Document?

If you are developing applications using Cocoa, you should read at least “Garbage Collection for Cocoa Essentials” to gain an understanding of the garbage collection system. It is strongly recommended that you also read “Adopting Garbage Collection” and “Implementing a finalize Method.” You are expected to already understand the Objective-C language (see The Objective-C Programming Language) and to have some familiarity with Cocoa.

Organization of This Document

The following articles explain the problems the garbage collection system addresses, the solutions it provides, its basic functionality, and common tasks you might perform:

See Also

The following documents provide information about related aspects of Cocoa and the Objective-C language.