Memory pool and its allocator for STL containers

Dear experts in C++

I am considering whether to utilize memory pool, and its use for allocation/deallocation via allocator. (such as boost::pool_allocator etc)

My program entails high frequent construction/destruction of vector or unordered_map containers, and particularly destruction takes high overhead.

Is it correct way to use memory pool and its allocator to minimize such a overhead?
(i.e. could memory pool allocator reduce time for destruction of STL containers?)

Kind regards
Is it correct way to use memory pool and its allocator to minimize such a overhead?
If the time is spent in destructors, and you keep calling them, not much is going to change.

Have you any idea what's taking the time?
Thank you for your kind reply.

I understand its simple use does not reduce overhead of destructor.

I guess the reason of taking time is because a lot of vector are.destructed as unordered_map<int, vector> or unordered_map<int,unordered_map<int,vector> >.
So, I am looking for some efficint way to use it with frequent generation and destruction.

vector's element is std::pair<int,int>
Last edited on
Perhaps you can use some kind of manager class that manages each cycle, but reuses the containers, thus reducing the setup/teardown costs.

It's difficult to say more from the information provided.
This topic is taken over in the below
<https://www.cplusplus.com/forum/general/273999/>
You messed up the link by adding the angle brackets.

https://www.cplusplus.com/forum/general/273999/
Topic archived. No new replies allowed.