#include <PoolMalloc.h>

Inheritance diagram for MemPoolMalloc:
Collaboration diagram for MemPoolMalloc:

Public Member Functions

 MemPoolMalloc (char const *label, size_t aSize)
 
 ~MemPoolMalloc ()
 
virtual bool idleTrigger (int shift) const
 
virtual void clean (time_t maxage)
 
virtual int getStats (MemPoolStats *stats, int accumulate)
 
virtual int getInUseCount ()
 
virtual MemPoolMeter const & getMeter () const
 
virtual MemPoolMetergetMeter ()
 
virtual void flushMetersFull ()
 
virtual void flushMeters ()
 
virtual void * alloc ()
 
virtual void freeOne (void *)
 
virtual size_t objectSize () const
 
virtual char const * objectType () const
 
void zeroBlocks (bool doIt)
 
int inUseCount ()
 
virtual void setChunkSize (size_t)
 

Static Public Member Functions

static size_t RoundedSize (size_t minSize)
 

Public Attributes

MemImplementingAllocatornext
 
size_t alloc_calls
 
size_t free_calls
 
size_t saved_calls
 
size_t obj_size
 

Protected Member Functions

virtual void * allocate ()
 
virtual void deallocate (void *, bool aggressive)
 

Protected Attributes

MemPoolMeter meter
 
int memPID
 
bool doZero
 

Private Attributes

std::stack< void * > freelist
 

Detailed Description

Definition at line 36 of file PoolMalloc.h.

Constructor & Destructor Documentation

MemPoolMalloc::MemPoolMalloc ( char const *  label,
size_t  aSize 
)

Definition at line 92 of file PoolMalloc.cc.

Referenced by getStats().

MemPoolMalloc::~MemPoolMalloc ( )

Member Function Documentation

void * MemImplementingAllocator::alloc ( )
virtualinherited

Allocate one element from the pool

Implements MemAllocator.

Definition at line 197 of file Pool.cc.

References MemImplementingAllocator::alloc_calls, MemImplementingAllocator::allocate(), FLUSH_LIMIT, and MemImplementingAllocator::flushMeters().

void MemPoolMalloc::clean ( time_t  maxage)
virtual
void MemPoolMalloc::deallocate ( void *  obj,
bool  aggressive 
)
protectedvirtual
void MemImplementingAllocator::freeOne ( void *  obj)
virtualinherited
int MemPoolMalloc::getInUseCount ( )
virtual
MemPoolMeter const & MemImplementingAllocator::getMeter ( ) const
virtualinherited
MemPoolMeter & MemImplementingAllocator::getMeter ( )
virtualinherited

Definition at line 355 of file Pool.cc.

References MemImplementingAllocator::meter.

bool MemPoolMalloc::idleTrigger ( int  shift) const
virtual

Implements MemImplementingAllocator.

Definition at line 103 of file PoolMalloc.cc.

References freelist.

int MemAllocator::inUseCount ( )
inherited

Definition at line 113 of file Pool.cc.

References MemAllocator::getInUseCount().

Referenced by memInUse(), and memStringCount().

size_t MemImplementingAllocator::objectSize ( ) const
virtualinherited

Implements MemAllocator.

Definition at line 361 of file Pool.cc.

References MemImplementingAllocator::obj_size.

char const * MemAllocator::objectType ( ) const
virtualinherited

Definition at line 107 of file Pool.cc.

References MemAllocator::label.

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

size_t MemAllocator::RoundedSize ( size_t  minSize)
staticinherited
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  )
inlinevirtualinherited

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)
inlineinherited

Definition at line 205 of file Pool.h.

References MemAllocator::doZero.

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

Member Data Documentation

size_t MemImplementingAllocator::alloc_calls
inherited
bool MemAllocator::doZero
protectedinherited

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 allocate(), deallocate(), MemChunk::MemChunk(), MemPoolChunked::push(), and MemAllocator::zeroBlocks().

size_t MemImplementingAllocator::free_calls
inherited
std::stack<void *> MemPoolMalloc::freelist
private

Definition at line 55 of file PoolMalloc.h.

Referenced by allocate(), clean(), deallocate(), and idleTrigger().

int MemImplementingAllocator::memPID
protectedinherited

Definition at line 268 of file Pool.h.

Referenced by MemImplementingAllocator::MemImplementingAllocator().

size_t MemImplementingAllocator::saved_calls
inherited

Definition at line 274 of file Pool.h.

Referenced by allocate(), MemImplementingAllocator::flushMeters(), and MemPoolChunked::get().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors