Date: 2001-08-30 15:16:49
> Since pool does not know the type of object that is being allocated, I
> presume this means that it always uses the maximal alignment
> for each chunk?
No. It uses certain properties to guarantee alignment, and to attempt
minimal alignment (though it will never get smaller than the alignment for
"void *"). The most important two properties are:
. "new char[N]" is properly aligned for any object of size N or smaller
. arrays do not have padding (though the objects in the array may have
Check out the "Guaranteeing Alignment" page of the Boost.Pool docs for more
info. I know it's not very readable; you might want to skip the
quasi-formal-proof stuff down to where it says "A Look at the Memory Block".
The splitting up of the block is based on the two properties above.
> I am allocating an array of objects with an initial reference count. Is
> there a solution in Boost.Pool for allocating these with minimum
> padding? I don't see one.
I'm not sure where your "reference count" is going (so I'm going to ignore
it here), but Boost.Pool does support allocation of arrays -- check out the
end of the "Guaranteeing Alignment" page to see how. These arrays contain
no more padding than ordinary arrays would.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk