3 ms·
> Using a single heap for all allocations is not at all ideal in an embedded context The same is true in game development. Using a per-frame arena allocator fo
by josephg 8y ago
> Using a single heap for all allocations is not at all ideal in an embedded context
The same is true in game development. Using a per-frame arena allocator for short lived objects can make a big difference to performance. And Rust’s lifetime rules can be used to make this sort of thing completely safe.
It’s a shame that rust std completely relies on the hidden global allocator instead of accepting an allocator as a parameter. It means that while you can write your arena allocator, you can’t use it with any of the built in Box/Vec/HashSet/etc types.
I actually really like Zig’s answer here of just passing in an allocator as an argument in all data structures. I’d love to see that in rust!
- steveklabnik 8y agoWe didn’t have an allocator API, or we would have liked to. Global allocators have finally stabilized. Working on it!