3 ms·
Garbage collection in Rust is thread-local. We never need concurrent GC; this invariant is enforced by the type system. Leaking cycles is not really an option,
by pcwalton 15y ago
Garbage collection in Rust is thread-local. We never need concurrent GC; this invariant is enforced by the type system.
Leaking cycles is not really an option, sorry. At the very least we're going to have a cycle collector. It's too easy to make cycles, especially when you have closures (all you need is to close over an object that contains a pointer to the closure itself; this is very common for e.g. event handlers).
Besides, a lot of the problems you state can be addressed with generational or incremental garbage collection.
- mkup 15y agoIf there is no difference on the syntactic level between owning and non-owning pointers, like in Go programming language, like in Python, then I agree with you - it's extremely easy to make a cycle. But if there's a difference between owning and non-owning pointer, then backlink to parent object in child object could be non-owning and other issues could handled in similar manner. Cycle detector which stops the program with references to the source code where the cycle was created - is a good idea, because in server systems under heavy load it just could be disabled. Basically it's a debugging tool, once it was proven by the testing that there are no bugs, these checks can be turned off in production. Like a C assertion checks.