Book Image

Objective-C Memory Management Essentials

Book Image

Objective-C Memory Management Essentials

Overview of this book

Table of Contents (18 chapters)
Objective-C Memory Management Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Memory management in Swift


Swift was created to avoid some of the downsides of C, one of which being memory management. Notice that nowhere in this chapter did I mention anything about pointers, memory allocation, deallocation, and so on. This is because in Swift, memory management is made to be as painless as possible so that you, the developer, can focus more on your application development than on debugging memory leaks. Every time a new instance of a class is created, ARC will allocate a chunk of the memory to be used to store information about that instance. This chunk of memory holds information such as the instance type (string, integer, and so on) along with the values of the properties that are associated with that instance. ARC will free up the memory used by that instance when it is no longer needed or referenced. This is to avoid a situation where instances still occupy precious memory space when they are no longer being used or needed.

However, if you try to access an instance...