Re:Modern garbage collection: Part 2
by steveklabnik on Saturday December 14, 2019 @04:24PM
(#21792364)
Arenas exist in stable too, this is just the arena the compiler uses internally. See packages like https://crates.io/crates/generational-arena or https://crates.io/crates/typed-arena
Re:Modern garbage collection: Part 2
by arcticbull on Saturday December 14, 2019 @05:27PM
(#21792756)
Ah of course, my bad, I must not have noticed. For some reason I read the "internal" flag as "nightly" :P
Re:Modern garbage collection: Part 2
by steveklabnik on Saturday December 14, 2019 @05:59PM
(#21792960)
It's all good!
The general approach used by games is probably superior, which are arenas or zones.
One approach games use is to allocate everything that's necessary for a given frame in a single large block, carve it off over time as needed, then drop the entire arena. All allocations then have memory locality, no fragmentation, basically zero cost to allocate (increment a pointer) and zero cost to deallocate.
This kind of thing actually plays really nicely with Rust's lifetimes since you can couple frame lifetime with objects in that frame and get static validation. Arenas are already available in nightly [1].
[1] https://doc.rust-lang.org/nightly/nightly-rustc/arena/index....