3 ms·
The OP mentioned that Objective-C's memory management is deterministic since it does not use a garbage collector. The major benefit is you know exactly when the
by millerm 13y ago
The OP mentioned that Objective-C's memory management is deterministic since it does not use a garbage collector. The major benefit is you know exactly when the memory is reclaimed (at zero references). You cannot determine when this will happen in Python (or any other GC language). That's all. And, there is no GC pause time in Objective-C's runtime so, that's awesome too. Another plus of ARC is that the compiler can place the release calls to your releasable instances closer to where they should be and can keep your memory foot print significantly lower, as code would be a lot harder to write with intertwined release calls in the middle of methods. A lot of people like to write their code in a structured form (like, release at the end of a method instead of 'inline' or 'immediate', I hope that makes sense) rather than high performance, due to readability.
- FooBarWidget 13y agoWhat? Python is ref counted. It releases at the time an object goes out of scope and has no references anymore... exactly like ARC. Although Python says its garbage collection is implementation-defined, in practice pretty much everybody uses CPython which uses refcounting. Where does the idea come from that Python releases at undeterministic time?
- duaneb 13y ago> Where does the idea come from that Python releases at undeterministic time? It's not the time that's undeterministic, it's that the 'deconstructor' may not be called at all if python can't guarantee collecting cyclical references in the right order. The object will still be released/deallocated. In this sense, Objective-C—mostly because you have complete control over the reference counting—has superior reference counting semantics. I'd like to note that there's nothing stopping Python from using similar approaches.