4 ms·
It's worth mentioning that there are several strategies for avoiding cascading deallocations like arenas or arena-backed graph abstractions. For example: https
by dikaiosune 10y ago
It's worth mentioning that there are several strategies for avoiding cascading deallocations like arenas or arena-backed graph abstractions. For example:
https://crates.io/crates/typed-arena https://crates.io/crates/typed-arena
https://crates.io/crates/petgraph https://crates.io/crates/petgraph
Rust's generics make this fairly pleasant to work with, and lifetimes/borrowck ensure safety when managing your own object allocations.
- naasking 10y agoIndeed, if you can live with the wasted memory use of objects outliving their conceptual lifetime, regions/arenas are a good solution. Note however that you'd probably still have to run destructors when destroying an arena (to free file handles for instance), so you can still see high latency. With an arena you can perhaps schedule this better though.
- dikaiosune 10y ago> if you can live with the wasted memory use of objects outliving their conceptual lifetime, regions/arenas are a good solution. If you can live with the wasted memory use of objects outliving their conceptual lifetime, garbage collectors can be a good solution too. Not that that's a bad thing for many use cases, but your above comment implies a comparison between Rust and GC. I think the quoted critique falls down a bit when Rust lets you opt-in to generational-esque GC-ish behavior with a very similar downside to what you'd get from a GC.