Important: Garbage Collection is deprecated in OS X v10.8. Instead, you should use Automatic Reference Counting—see Transitioning to ARC Release Notes.
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
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:
Garbage Collection for Cocoa Essentials describes the essential details of the garbage collection system for Cocoa. At a minimum, you should read this article.
Adopting Garbage Collection describes issues related to adopting garbage collection.
Architecture describes the design goals and architecture of the technology, and the benefits you get from using it.
Using Garbage Collection describes some of the features you can take advantage of when you use garbage collection, and some of subtleties you need to be aware of.
Implementing a finalize Method describes how to correctly implement a
Inapplicable Patterns describes Cocoa programming patterns that are not applicable to garbage collection.
Using Core Foundation with Garbage Collection describes how to use Core Foundation objects with garbage collection.
Garbage Collection API provides a summary of API used in garbage collection.
The following documents provide information about related aspects of Cocoa and the Objective-C language.
The Objective-C Programming Language describes object-oriented programming and describes the Objective-C programming language.
Objective-C Runtime Reference describes the data structures and functions of the Objective-C runtime support library.
Transitioning to ARC Release Notes provides information adopting Automatic Reference Counting.