Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

How does memory_pool reuse freed memory?

Devin_B_
Beginner
87 Views
typedef tbb::memory_pool<tbb::scalable_allocator<char>> MemoryPool;

I have one use case where I need to store objects for a long time. However, for this use case I also need to do a lot of malloc and free calls. After I free an object, does the memory_pool implementation fill previously freed blocks when calling malloc? If yes, are there any limitations?

 

0 Kudos
2 Replies
Alexei_K_Intel
Employee
87 Views

The short answer is that the memory_pool implementation reuses previously freed blocks when calling malloc if possible. However, the algorithm logic is too complex to be described in one answer. It would be great if you provide a bit more details about your memory access pattern: What are the typical allocation sizes? Do you have multithreaded allocations? Do you allocate and deallocate memory on the same thread?

Regards, Alex

Ziv_G_Intel
Employee
87 Views

As Alex said, we need more information in order for us to give you a hand with this.

 

 

Reply