▲ | nayuki 3 days ago | |
> Arc isn't really garbage collection. It's like a reference counted smart pointer Reference counting is a valid form of garbage collection. It is arguably the simplest form. https://en.wikipedia.org/wiki/Garbage_collection_(computer_s... The other forms of GC are tracing followed by either sweeping or copying. > If you drop an Arc and it's the last reference to the underlying object, it gets dropped deterministically. Unless you have cycles, in which case the objects are not dropped. And then scanning for cyclic objects almost certainly takes place at a non-deterministic time, or never at all (and the memory is just leaked). > Garbage collection generally refers to more complex systems that periodically identify and free unused objects in a less deterministic manner. No. That's like saying "a car is a car; a vehicle is anything other than a car". No, GC encompasses reference counting, and GC can be deterministic or non-deterministic (asynchronous). |