Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
24 Views

How does memory_pool reuse freed memory?

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
Highlighted
Employee
24 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

0 Kudos
Highlighted
Employee
24 Views

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

 

 

0 Kudos