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.