
4 May
2012
4 May
'12
11:44 p.m.
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. Cheers, Sylvain