#include <OTC/memory/cmmnpool.hh> class OTC_CommonPool {
public:
friend class OTC_CommonPoolDummy;
static void* allocate(size_t theSize);
static void release(void* theMem, size_t theSize);
};
OTC_CommonPool
is a common memory pool for small
objects.
Currently 8
pools are created, with the size of the pools
varying by sizeof(double)
. Thus, on 32
bit machines, there will
be pools ranging from 8
bytes to 64
bytes, with a 8
byte
difference in the size of each pool. If a piece of memory larger
than 64
bytes is requested, the global new
and delete
are
used.
All the pools can be disabled and the global new
and delete
used for all memory, by defining the environment variable
OTCLIB_NOCOMMONPOOL
.
static void* allocate(size_t theSize);
theSize
.
static void release(void* theMem, size_t theSize);
theMem
. theSize
should be
the same as the size used to originally
allocate the memory. If the memory was
not originally allocated from this
pool, the result is undefined.
operator new()
and operator delete()
to use this class will be derived from. The class must have a
virtual destructor.
OTC_Pool