I am coming from a C# background; as I understand it Swift have automatic memory management like C# does.
An issue in C# that requires the use of “programming patterns” is the timely releasing of resources, as the garbage collector runs at an undefined time, and hence cannot be used to close files, release network connection etc. (Hence IDisposable and the “using” keyword)
How is this dealt with when programming in Swift?
Swift seems to use there same memory management model like Objective-C with ARC enabled.
That means there is no garbage collector. Instead ARC uses reference counting with compiler inserted increment and decrement operations when (strong) references are being set.
The absence of a (threaded) collector means finalization is deterministic in Swift. Objects are deallocated when the last reference goes out of scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With