|
|
|
|
|
by eru
687 days ago
|
|
> You can, but it turns out that, as one may intuitively expect, a GC is never needed unless [...] Rust uses plenty of reference counting. You could replace most of that with a GC; depending on your GC implementation and your reference counting implementation, and your requirements in terms of latency and throughput and ability to handle cycles. > Since it's not needed and it's massively worse than reference counting (assuming you only change reference counts when essential and use borrowing normally) due to the absurd behavior of scanning most of the heap at arbitrary times, there is no Rust GC crate in widespread use. There are choices. You can have real time garbage collectors. And if you want to handle cycles, you need some kind of tracing anyway. Also, if you only care about throughput and not about latency, garbage collection can easily be faster than reference counting. If you don't allow cycles, you can also take advantage of that in your garbage collection. See how Erlang does it. (In Erlang, the garbage collector relocates your objects so that they are in topological order, so all references only point forwards in memory. You can combine that with generational gc, too, of course.) |
|