Chapter 9. Memory management

 

This chapter covers
  • Object lifetime management
  • Manual memory management via retain and release messages
  • Autorelease pools and the autorelease message
  • Object ownership rules
  • Memory management rules for custom classes

 

Many developers new to Objective-C find memory management one of the most difficult concepts to wrap their heads around. This is especially true for those coming from an environment such as Java, .NET, ActiveScript, or Ruby, where memory management is a much more automated, behind-the-scenes process.

In Objective-C all objects are created on the heap (unlike languages such as C++, which also allow objects to be placed on the stack). This means objects continue to consume memory until they’re ...

Get Objective-C Fundamentals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.