Memory management

When we talk about memory management, we are talking about managing heap memory. Consider the difference between the stack and the heap. Recall from Chapter 5 that the stack is an orderly stack of frames. Each frame is automatically deallocated when the function using it ends. The heap, on the other hand, is a heaping pile of memory, and that is where your objects live.

Managing the heap is important because objects can be large and because your program only gets so much heap memory for its own use. Each object that is created takes up some of that memory.

Running low on memory is a problem. It will cause a Mac app to perform badly and will cause an iOS app to crash. Thus, it is essential that any objects that ...

Get Objective-C 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.