From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-08-30 16:05:08


----- Original Message -----
From: <scleary_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, August 30, 2001 4:16 PM
Subject: [boost] RE: Pool question

> > 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
> padding)
>
> 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
> permissible
> > padding? I don't see one.
>
> I'm not sure where your "reference count" is going

At the front, which is what I meant by "initial". Specifically:

+-------+----------+------+------+
| count | padding? | elt1 | elt2...
+-------+----------+------+------+

> (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.

I'll look at the docs some more, but if you have answers to the above, they
would be very much appreciated.

Thanks again,
Dave