fast_pool_allocator, std::multi_map and purge_memory

Hi, I have written a small test program to measure the performance benefit of using a boost::fast_pool_allocator vs the default system allocator in conjunction with a std::multi_map. Memory overhead is ~16% lower and the boost allocator is ~4x faster - sweet. However, I can't release the allocated memory via the singleton_pool interface as described in the documentation. In my test program quoted below the call to purge_memory always returns 0 and according to window's task manager the memory has not been released. An even simpler test just using an allocator for ints and allocating/relasing/purging 10.000.000 ints works as expected. What am I doing wrong? cheers, Sören PS: I'm using boost 1.39 with MSVC2008 #include <map> #include <iostream> #include <boost/pool/pool_alloc.hpp> int main( int, char ** ) { typedef boost::fast_pool_allocator< std::pair< int, void * > > TPoolAllocator; typedef std::multimap< int, void *, std::less< int >, TPoolAllocator > TMap; { TMap map; for ( int i = 0; i < 10000000; ++i ) map.insert( std::make_pair( rand() % 100, (void *)0 )); } std::cout << boost::singleton_pool< boost::fast_pool_allocator_tag, sizeof( TPoolAllocator::value_type ) >::purge_memory(); return 0; }

AMDG Soeren Meyer-Eppler wrote:
I have written a small test program to measure the performance benefit of using a boost::fast_pool_allocator vs the default system allocator in conjunction with a std::multi_map. Memory overhead is ~16% lower and the boost allocator is ~4x faster - sweet. However, I can't release the allocated memory via the singleton_pool interface as described in the documentation.
In my test program quoted below the call to purge_memory always returns 0 and according to window's task manager the memory has not been released. An even simpler test just using an allocator for ints and allocating/relasing/purging 10.000.000 ints works as expected. What am I doing wrong?
std::multi_map doesn't allocate object of the value_type. It uses Allocator::rebind to allocate objects of its internal node type, which contains extra member. In Christ, Steven Watanabe

std::multi_map doesn't allocate object of the value_type. It uses Allocator::rebind to allocate objects of its internal node type, which contains extra member.
Thanks for the quick reply Steven. Your explanation makes perfect sense - however it also presents a problem: how do I deallocate memory now? As far as I can tell the STL that ships with MSVC has the map's internal _Node datatype protected. So aside from guessing the correct size of it - how can I tell what the proper singleton pool is? cheers, Sören
participants (2)
-
Soeren Meyer-Eppler
-
Steven Watanabe