I started using boost pools as singleton defined in boost / pool / singleton_pool.hpp, since I need to create many structures of the same size multiple times. The performance improvement is phenomenal since I used malloc before.
The objects that I select are put into the list by the producer thread, and the consumer stream transfers them from the other end and frees the objects. But when I free the object, the memory usage in the task manager never decreases. I assume this is due to the fact that a certain amount of memory is pre-allocated by the pool library?
Also, when the manufacturer's data rate increases, the total memory usage appears to increase in chunks of ~ 10k, but never decreases even after a free call for objects in the pool.
I would like some of the houses to be kept periodically to free up chunks of memory in order to reduce the overall memory usage in the process. Is it possible? I cannot use purge_memory, as this will mean that I will have to synchronize the cleaning between producers and consumers. BTW does purge_memory frees a piece, i.e. Reduces memory usage in task manager?
I program in MS windows.
Thanks Niladri
PS - I tried using release_memory, making the pool ordered (ordered_malloc), but always returns false.
UPDATE:
Do not try purge_memory while the pool is split between two threads. But they found that release_memory works, but only for ordered pools and slowly frees memory, since it frees only blocks of memory without allocation.
Cleaning will work faster. I'm sure.
source share