Edit AllPages

Memory Management Overview Page

MemoryManagement is a very central topic to programming. Many different systems for MemoryManagement have been devised, but since this is a Cocoa site, we can ignore most of them.

In Cocoa with Objective-C, MemoryManagement is handled by RetainingAndReleasing objects. Starting with Objective-C 2.0 and Mac OS X 10.5, and also when you are programming Cocoa with Java, you have the added option of using GarbageCollection.

The best thing you can do to learn memory management is to read the first two lines of RulesOfThumb. Then read them again.

=== ARC === Just to confuse things, in the most recent versions of Xcode (4.5 and higher), there is “ARC”, or Automatic Reference Counting. For many programmers, this will vastly simplify everything, since to use it, you simply set the project to use it, and then get rid of all your retain, release, and autorelease calls. Dealloc’s become mostly empty, most can go away.

Note that ARC might have an impact on performance compared to tight memory management. However, the vast majority of programs will not suffer. Release notes and documentation should be carefully studied before working around it.

CocoaDev articles dealing with MemoryManagement: [Topic]


External articles dealing with MemoryManagement

* - “Memory Management Programming Guide for Cocoa” * - “The Life Cycle of a Cocoa Object” * - “Hold Me, Use Me, Free Me.” By: Don Yacktman. * - “Very simple rules for memory management in Cocoa” By mmalcolm crawford * - “Accessor Methods Revisited” By mmalcolm crawford * - an article on the subject by RobRix. * - Allocation Basics & Foundation - an article in the series on optimizing Objective-C. * - Podcast on what memory is and memory management in Cocoa with Steve Scott and Uli Kusterer. * - A chapter from a C tutorial aimed at Mac programmers that explains what memory is. * - “Memory Management in Cocoa”, from an upcoming eBook by the {13bold} duo

*Learning the basics of buffer overflows [] *Self-manage data buffer memory []