3Managing Memory with ARC

In this chapter, you’ll learn how memory is managed in iOS and the concepts that underlie automatic reference counting, or ARC. We’ll start with some basics of application memory.

The Heap

All Objective-C objects are stored in a part of memory called the heap. When we send an alloc message to a class, a chunk of memory is allocated from the heap. This chunk includes space for the object’s instance variables.

For example, consider an instance of NSDate, which represents a specific point in time. An NSDate has two instance variables: a double that stores the number of seconds since a fixed reference point in time and the isa pointer, which every object inherits from NSObject. A double is eight bytes, and a pointer is ...

Get iOS Programming: The Big Nerd Ranch Guide 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.