
Klaus Nowikow wrote:
Hi!
I am in the process of writing a program which has to handle large numbers (~200000 - 400000) objects of the same class. These objects will be created and deleted frequently, so I thought some kind of specialized memory management would be handy.
I wrote a test program (see below) to check what boost.pool would gain me. The results make me think that I have done something wrong:
debug mode: std::allocator 2.17s boost::pool_allocator 7.18s
release mode: std::allocator 0.11s boost::pool_allocator 0.36s
i.e., std::allocator was more than 3 times faster than boost::pool_allocator (Win2k, 256MB). Any ideas what i have done wrong?
[...]
template <class Allocator> double Test() { std::vector<Allocator::value_type, Allocator> Vector; boost::timer Timer;
for(int i = 0; i < NUM_ELEMENTS; ++i) { Vector.push_back(i); }
return Timer.elapsed(); }
If I read the code correctly, you don't create or delete objects. You create and delete (large) arrays of objects.