Subject: Re: [boost] [pool] Objects of varying sizes
From: Robert Dailey (rcdailey.lists_at_[hidden])
Date: 2012-05-07 11:35:34
On Fri, May 4, 2012 at 6:44 PM, Sylvain Bougerel <
> > 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!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk