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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access