I'd like to use an arena allocator to allocate ref object s (for spatial locality). Is it possible get ref object s to allocate on my specific memory region? I'm thinking something like emplace in D: https://dlang.org/phobos/core_lifetime.html#.emplace.3.
I'd also like to explore freeing the arena all at once but I'm assuming that'd break the ARC.
I can do what I have mind with plain object s and getters returning var T but I lose the ability to that with library types.
I'd like to use an arena allocator to allocate ref object s (for spatial locality)
Nim's allocator already understands the importance of "spacial locality".
but I lose the ability to that with library types.
Yes indeed. It also does not matter. The parts of the stdlib that allocate heavily don't work well with the idea of a bulk free operation anyway. Been there, done that.
Usually allocator being a bottleneck only concerns few types in your code. In that case, it's almost always better to use ptr object and create a specific scheme like an object pool or memory pool.
A generic solution will likely not address specific use-cases, might be overcomplicated to handle everyone's specific edge cases and be a maintenance nightmare.