Boost logo

Boost :

Subject: Re: [boost] [pool] Objects of varying sizes
From: Robert Dailey (rcdailey.lists_at_[hidden])
Date: 2012-06-25 18:00:18

On Mon, May 7, 2012 at 10:35 AM, Robert Dailey <rcdailey.lists_at_[hidden]>wrote:

> On Fri, May 4, 2012 at 6:44 PM, Sylvain Bougerel <
> sylvain.bougerel.devel_at_[hidden]> wrote:
>> > Is it possible to create a pool for polymorphic types? For example:
>> >
>> > class A;
>> >
>> > class B : public A;
>> > class C : public A;
>> >
>> Well, if class B and C have additional members (if they are not empty
>> classes) you will need to use a memory pool that is capable of allocating
>> varying amount of contiguous memory. I don't see why this is not possible.
>> Have you looked at Boost.Pool? It uses a free list and allocate varying
>> amounts of chuncks of memory, based on your request. If you choose an
>> appropriate size for the small chunk, then you may be able to dynamically
>> allocate without wasting too much space.
> My post was actually in regards to Boost.Pool. I don't see how to use
> Boost.Pool for objects of varying sizes. I was looking at the object pool,
> which accepts a type, but it wouldn't know that I require varying sizes
> just by looking at 1 type. Each subclass would ideally have more data
> members, so the sizes would not be the same depending on which concrete
> type I'm allocating.
> Could you provide an example if it's not too much trouble? Thanks!

Any advice for me on this?

Boost list run by bdawes at, gregod at, cpdaniel at, john at