O'Reilly logo

Application Development with Swift by Hossam Ghareeb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Memory management

Memory management is one of the most important topics that every developer should be aware of when making their app very responsive and efficient. Swift uses Automatic Reference Counting (ARC) to manage memory. In ARC, freeing up memory and managing it is done automatically when instances are no longer needed. Although ARC does most of the work in memory management, you have to care about the relations between classes to avoid memory leaks.

In memory, each object has a reference counting, and when it reaches zero, this object will be deallocated from the memory. In Swift, we have two types of references: strong and weak. The strong references retain the object and increment its reference counting by 1; the weak references don't ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required