3 ms·
> RAII handles that perfectly. I'm not sure about this. If you're asking whether arena allocators can handle resource cleanup, then I think the answer is yes.
by creata 4y ago
> RAII handles that perfectly. I'm not sure about this.
If you're asking whether arena allocators can handle resource cleanup, then I think the answer is yes. One way to do it is to embed an intrusive linked list of destructors into your arena. So, to push an object onto the arena you would:
1. Push a function pointer (the object's destructor) and the current destructor list head onto the arena.
2. Update the destructor list head to point to the top of the arena.
3. Push the object's data onto the arena, as usual.
(source: https://www.ea.com/frostbite/news/scope-stack-allocation https://www.ea.com/frostbite/news/scope-stack-allocation)