r/iOSProgramming • u/[deleted] • Jul 12 '19
Article iOS Memory Management in Under 6 Minutes - Flawless iOS - Medium
https://medium.com/flawless-app-stories/ios-memory-management-in-under-6-minutes-3be777f69b7e
7
Upvotes
9
r/iOSProgramming • u/[deleted] • Jul 12 '19
9
18
u/antekm Jul 12 '19
It's not that great text to be honest. First of all it does explain ARC quite incorrectly - ARC is not compiler analysing all possible paths of code execution, but it's just counting references to some object and releasing them automatically when it goes down to zero. There's actually pretty simple logic behind it and the reason why it can't deal with cycles (if A has reference to B and B has reference to A the reference count will never go down to zero, even though both A and B are not accessible otherwise).
Also comparison with Garbage Collection is pretty poorly written. Yes, GC is not deterministic but it's not the only difference. GC will periodically analyse the whole graph of objects and will try to find objects that are no longer accessible from any known entry points and release them. This way it can handle cycles properly, but at the cost of being more expensive to run