3 ms·
In Rust, garbage collection is just a library type (akin to the Boehm GC for C++). And because the language expects to get by 99.9% of the time without any GC a
by kibwen 13y ago
In Rust, garbage collection is just a library type (akin to the Boehm GC for C++). And because the language expects to get by 99.9% of the time without any GC at all, other facets of the language design will necessarily restrict the strategies of GC that can be supported. For example, Rust allows you to store pointers directly into data structures, which means that a moving GC would need to be able to know about all references to any data that has been moved and update all pointers in memory appropriately. Rust isn't a language that's willing to pay that sort of dynamic bookkeeping cost, so the GC in Rust's stdlib will probably never be moving or compacting.
Disclaimer: not a GC expert!
- dbaupp 13y agoThere is scope for moving/compacting GC, as long as creating a reference from a GC pointer is registered and pins a GC allocation in place until the reference disappears (i.e. it will theoretically only be a cost with GC pointers, not anything else). Also it's worth noting that Rust does not have a GC yet, and I don't believe anyone has really got in there and iterated on possibilities yet. (Graydon, Felix (pnkfelix) and I have all done some experimentation with it, but all proof-of-concept/very basic, not really bullet-proof/production-ready things.)