3 Managing Memory with ARC

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

The Stack

When a method (or function) is executed, a chunk of memory is allocated from a part of memory called the stack. This chunk of memory is called a frame, and the frame stores the values for variables declared inside the method. A variable declared inside a method is called a local variable.

When an application launches and runs main(), the frame for main() is put on the stack. When main() calls another method (or function), the frame for that method is put on top of the stack. Of course, that method could ...

Get iOS Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.