Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2464 Discussions

Does tbb:concurrent_queue grow like std::vector? How to release its buffers?

den_jekk
Beginner
316 Views

Hello, I'm wondering if tbb:concurrent_queue can grow its internal buffers when it's under high load, and then not release the buffers?

How to obtain any information about the buffers and/or release them?

In the vector, you have methods like .reserve() to allocate and .swap(vector()) to completely release any buffers.


Regards,
Denis

0 Kudos
3 Replies
Anton_M_Intel
Employee
316 Views
pop() deallocates free pages as well as clear() and assign(). Do you have any experimental evidence that tbb::concurrent_queue keeps free buffers allocated? Can it be tbb_allocator/scalable_allocator instead which doesn't return the memory to the system immediately?

A small addition regarding vector, it also has shrink_to_fit() in C++0x and TBB, formerly known as compact() in tbb::concurrent_vector.
0 Kudos
den_jekk
Beginner
316 Views
Is the scalable_allocator used by default? I will now investigate the case, but maybe you have already the information. Is it possible to get total amount of memory occupied by a scalable allocator?
0 Kudos
Anton_M_Intel
Employee
316 Views
Yes, because default allocator for concurrent_queue<> is cache_aligned_allocator<> which uses scalable_allocator by default if tbbmalloc.dll is in the paths. BTW, it can be [mostly] changed by template argument:
concurrent_queue >

No, I guess there is no way to query such an information from scalable allocator. But actually you can reuse this memory anyway by using it for next allocations ;-)
0 Kudos
Reply