fn run_query(alloc) {
arena = init_arena(alloc);
defer arena.deinit();
}fn run_query(alloc) {
arena = init_arena(alloc);
defer arena.deinit();
}eg https://www.dgtlgrove.com/p/untangling-lifetimes-the-arena-a...
that being said, it's even easier to not manage any lifetimes at all :)
although i suppose some will say that you still manage lifetimes in rust, you just have full support from the compiler to make sure you do it right. that seems better to me than relying on simplification to ensure you don't make mistakes.
For example, bump style allocators allocate very quickly, but at the cost of higher memory usage and therefore sometimes worse cache locality.
The only way to know is to actually measure.
> I think it should be preferred wherever it's an option for that reason most of all.
And that’s far too broad in my opinion.
Sure, if you’re writing in a language that makes memory management difficult, like C or Zig, that might be worth it, but arena allocators apply to many other languages too.
Yes, which you didn't respond to until now.
> And that’s far too broad in my opinion.
Similarly, it's far too broad to say that it's "much less error prone" to use a more general allocation strategy. Clearly we both make unspoken assumptions, but in the context of this discussion on Zig, where you initially responded to an example written in Zig, I think you actually understood what I meant.
It makes it much easier to avoid lifetime mistakes in my experience.
Using arena allocation also makes me think more about how much memory I am using and how much memory I should be using etc.
It is hard to benchmark it against just using a global allocator because it is a structural change to the whole codebase.
But, you can use hashmaps fine. Just need to think about it and structure the program well for it.
It becomes clear once you do it a couple of times