Memory pool and its allocator for STL containers

Nov 9, 2020 at 8:19am
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
Nov 9, 2020 at 2:11pm
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?
Nov 9, 2020 at 8:19pm
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 Nov 9, 2020 at 8:25pm
Nov 9, 2020 at 11:28pm
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.
Nov 10, 2020 at 5:36am
This topic is taken over in the below
<https://www.cplusplus.com/forum/general/273999/>
Nov 10, 2020 at 8:48pm
You messed up the link by adding the angle brackets.

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