Memory management in swift is handled with ARC (= automatic reference counting). This means that active references to objects are counted and objects are released when they aren’t referenced anymore.
In Objective-C (especially in the old days of Objective-C, before the introduction of ARC) it was necessary to retain and release objects manually. Developers needed to manage the memory of each object and mistakes in memory management could result in memory leaks or crashes.
In Swift memory management is done automatically through ARC and in most cases developers do not need to worry about managing it. There are some exceptions though. For example:
- References to self in closures that can mess with ARC
- Uses of Objective-C objects in swift
References to self in closures can be handled by using the keywords weak and unowned. I wrote a small blogpost about it here:
Uses of Objective-C objects in swift can lead to these objects not being correctly released. The fix for this issue is autoreleasepool.