3 ms·
Reference counting is a (low-throughput, low-latency) form of garbage collection.
by giornogiovanna 7y ago
Reference counting is a (low-throughput, low-latency) form of garbage collection.
- arcticbull 7y agoYes and no. From a theoretical perspective, I suppose that's true, but "garbage collection" tends to mean a non-deterministic collector that does its own thing, and you don't have to think at all about memory. That does not apply to Swift, as of course, you need to understand the difference between strong and weak references. It's unfairly simplistic to couple the two.
- staticassertion 7y agoBut it actually is just garbage collection.
- Sean1708 7y agoIt is but in the context of this discussion it's very clear that they meant a tracing garbage collector, which has a very different cost than atomic reference counting. Or to put it another way: you're technically correct, the worst kind of correct.
- barrkel 7y agoNo, RC is GC. Most people think of Python as GCed language, and it uses mostly RC. Any runtime that uses mark & sweep today may elect to use RC for some subset of the heap at some point in a future design, if that makes more sense. The mix of marking GC vs refcounting GC shouldn't affect the semantics of the program.
- _ph_ 7y agoThe low-latency part might not even be true. RC means that you don't have CPU consuming heap scans, but if you free the last reference to a large tree of objects, freeing them can take quite a lot of time, causing high latencies.