-
I've been looking for a replacement for the boost fast_pool_allocator. I've got the memory library linked in now, but I'm running into a few issues with actually using it as a replacement. The boost allocators are backed by pools that are owned by singletons, so they get automatically created. Is there something equivalent with this library? From what I'm understanding, I need to expressly create each pool I want to use. The unordered_map is a member of an class, but I'd like all the instances of the class to share a single pool for that map if possible. I was trying to create the pool as a static member of the class, but I'm having trouble figuring out how to properly initialize the pool. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To be frank, none - unordered_map wants both array and individual node allocation, which isn't ideal. The closest would be
No, you had to roll it your own. Something like: auto& pool()
{
static memory_pool<array_pool> pool;
return pool;
} (Keep in mind that this can cause issues with destruction order though.) |
Beta Was this translation helpful? Give feedback.
-
@rwis42 You could use a This is what we are doing on Fast DDS here. Mind that our use case is pre-allocating a known maximum number of nodes, so we know that the array allocation will only be called once at startup. |
Beta Was this translation helpful? Give feedback.
To be frank, none - unordered_map wants both array and individual node allocation, which isn't ideal. The closest would be
memory_pool<array_pool>
, but you should benchmark whether it's actually faster.No, you had to roll it your own.
Something like:
(Keep in mind that this can cause issues with destruction order though.)