Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-01-18 07:00:37


Svaley Streasm wrote:
> Hi,
>
> I understand that shared_ptr uses the 'quick_allocator' when I
> compile the library with BOOST_SP_USE_QUICK_ALLOCATOR. But this
> means that I get the 'quick_allocator' working for every type that I
> use with shared_ptr, and this bothers me because this seems as a
> waste of memory for instances of classes that are not frequently
> used.

Quick_allocator uses a common heap when classes have the same size and
alignment. Since shared_ptr uses quick_allocator for its control block (the
class derived from sp_counted_base), and since these usually differ only by
the pointer type, the typical program only uses a single heap.

Of course you should use the quick_allocator only when the underlying
malloc/operator new doesn't implement the small object optimization well
enough, otherwise just let it do its thing. You can use
shared_ptr_alloc_test to time it.


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