Chapter 24. Memory Management

Garbage collection is a recent feature in Objective-C and, while this is a huge step in the right direction, it's not universally available. The alternative is traditional Objective-C managed memory, wherein your code takes responsibility for destroying objects.

The principal reasons you'd choose to use managed memory instead of garbage collection are as follows:

  • The operating system or compiler doesn't support garbage collection (specifically, this is the case with the iPhone OS and older versions of Mac OS X).

  • You're working on a project that's already using managed memory.

  • The code must function in a managed memory environment (for example, a plug-in).

In the first case, your only choice is to embrace managed memory. ...

Get Learn Objective-C for Java Developers 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.