3 ms·
This is just manually implemented garbage collection, really.
by dralley 3y ago
This is just manually implemented garbage collection, really.
- vardump 3y agoGarbage collection is not necessarily memory compacting.
- 10000truths 3y agoNot really. Compaction is a feature of many garbage collectors, but the allocator I described doesn't impose any particular way of deciding how and when to deallocate the objects. You could do so explicitly with a MyAllocator::deallocate() method, or use runtime reference counting, or (if you're willing to constrain handle lifetimes to the allocator lifetime) you could delete the allocator entry when the handle goes out of scope.
- danhau 3y agoI kind of agree. A while ago I was thinking about how to implement something like Roslyn's red-green-trees in Rust. The solution I came up, with a similar in principle handle-and-allocator approach, did work, but would need the occasional cleanup, to get rid of zombie objects. At that point I realised that all I've done was reinvent a poor mans garbage collector.