#include <Pool.h>

Inheritance diagram for MemAllocator:
Collaboration diagram for MemAllocator:

Public Member Functions

 MemAllocator (char const *aLabel)
 
virtual ~MemAllocator ()
 
virtual int getStats (MemPoolStats *stats, int accumulate=0)=0
 
virtual MemPoolMeter const & getMeter () const =0
 
virtual void * alloc ()=0
 
virtual void freeOne (void *)=0
 
virtual char const * objectType () const
 
virtual size_t objectSize () const =0
 
virtual int getInUseCount ()=0
 
void zeroBlocks (bool doIt)
 
int inUseCount ()
 
virtual void setChunkSize (size_t)
 

Static Public Member Functions

static size_t RoundedSize (size_t minSize)
 

Protected Attributes

bool doZero
 

Private Attributes

const char * label
 

Detailed Description

a pool is a [growing] space for objects of the same size

Definition at line 178 of file Pool.h.

Constructor & Destructor Documentation

MemAllocator::MemAllocator ( char const *  aLabel)

Definition at line 289 of file Pool.cc.

virtual MemAllocator::~MemAllocator ( )
inlinevirtual

Definition at line 182 of file Pool.h.

Member Function Documentation

virtual int MemAllocator::getInUseCount ( )
pure virtual
virtual MemPoolMeter const& MemAllocator::getMeter ( ) const
pure virtual

Implemented in MemImplementingAllocator.

Referenced by cbdataDump(), and Mem::Report().

virtual int MemAllocator::getStats ( MemPoolStats stats,
int  accumulate = 0 
)
pure virtual
Parameters
statsObject to be filled with statistical data about pool.
Return values
Numberof objects in use, ie. allocated.

Implemented in MemPoolMalloc, and MemPoolChunked.

Referenced by memPoolGetGlobalStats(), and Mem::Report().

int MemAllocator::inUseCount ( )

Definition at line 113 of file Pool.cc.

References getInUseCount().

Referenced by memInUse(), and memStringCount().

virtual size_t MemAllocator::objectSize ( ) const
pure virtual

Implemented in MemImplementingAllocator.

Referenced by cbdataDump().

char const * MemAllocator::objectType ( ) const
virtual

Definition at line 107 of file Pool.cc.

References label.

Referenced by cbdataDump(), MemPoolChunked::getStats(), and MemPoolMalloc::getStats().

size_t MemAllocator::RoundedSize ( size_t  minSize)
static
Parameters
minSizeMinimum size needed to be allocated.
Return values
nSmallest size divisible by sizeof(void*)

Definition at line 293 of file Pool.cc.

Referenced by GetStrPool().

virtual void MemAllocator::setChunkSize ( size_t  )
inlinevirtual

Allows you tune chunk size of pooling. Objects are allocated in chunks instead of individually. This conserves memory, reduces fragmentation. Because of that memory can be freed also only in chunks. Therefore there is tradeoff between memory conservation due to chunking and free memory fragmentation.

Note
As a general guideline, increase chunk size only for pools that keep very many items for relatively long time.

Reimplemented in MemPoolChunked.

Definition at line 218 of file Pool.h.

Referenced by createRemovalPolicy_lru(), and Mem::Init().

void MemAllocator::zeroBlocks ( bool  doIt)
inline

Definition at line 205 of file Pool.h.

References doZero.

Referenced by Mem::AllocatorProxy::getAllocator(), GetStrPool(), and memDataInit().

Member Data Documentation

bool MemAllocator::doZero
protected

Whether to zero memory on initial allocation and on return to the pool.

We do this on some pools because many object constructors are/were incomplete and we are afraid some code may use the object after free. These probems are becoming less common, so when possible set this to false.

Definition at line 233 of file Pool.h.

Referenced by MemPoolMalloc::allocate(), MemPoolMalloc::deallocate(), MemChunk::MemChunk(), MemPoolChunked::push(), and zeroBlocks().

const char* MemAllocator::label
private

Definition at line 236 of file Pool.h.

Referenced by objectType().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors