Boost Users :
Subject: [Boost-users] [Pool] correct usage for optimal performance
From: Igor R (boost.lists_at_[hidden])
Date: 2009-12-07 08:31:26
In my application I use singleton pools for the 2 most common
1) Frequent allocation of small objects (one by one, tens to hundreds
per second). Every object is disposed soon after its allocation, so
that only few objects are alive simultaniously.
Since the objects are accessed through shared_ptr, I allocate them as follows:
Is this the appropriate use of Pool for this scenario? Should I use
pool_allocator (i.e. ordered_malloc()) instead?
2) Frequent (same as in (1) frequency and lifetime) allocation of
memory blocks that look like this: [10Kb, 1Kb, 1.1Kb, 0.9Kb,...
10.5Kb...] - i.e. 1 big block, then several small ones. Each block is
stored in shared_array, and I allocate it this way:
typedef boost::singleton_pool<my_alloc_tag, 1024> allocator;
int chunks = blockSize / allocator::requested_size + 1; // rough aproximation
bind(&allocator::free, _1, chunks));
Again, should I use here ordered_xxx? Or probably it's worth using
allocator::maloc for the case of chunks==1, and ordered_malloc for
chunks > 1?
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