|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-05-08 05:46:21
Darren Cook wrote:
>
> Anywhere in Boost is fine by me; currently it is in boost::detail and
> not in the documentation.
Given enough pressure... and documentation... and tests... ;-)
> OK. How about a template parameter to specify page size? We could use
> the platform and the class size to guess a good default.
Having all allocators share a single page size is good since it allows them
to pool objects of different types together, if their sizes and alignments
match. I.e. quick_allocator<int> and quick_allocator<void*> can share pools.
This helps a lot.
> Where I'm going with this is if I know from profiling that typically
> my program will peak at using 1000 objects, then I can simply change
> the page size to be that big (maybe rounded up to a certain multiple
> - does incorrect page size matter much if there is just one
> allocation?). Just as I would use reserve() with vector, and just
> like that I know it can expand if usage is non-typical.
It seems to me that the right way to provide this functionality is to just
add a reserve() member function; no need to fake it by changing the page
size. But I'm not sure whether it's really worth it. Please experiment with
it a bit. It may turn out that preallocation isn't really necessary.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk