Boost logo

Boost Users :

Subject: [Boost-users] fast_pool_allocator, std::multi_map and purge_memory
From: Soeren Meyer-Eppler (Soeren.Meyer-Eppler_at_[hidden])
Date: 2009-08-31 10:06:12


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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net