#include <PoolChunked.h>

Inheritance diagram for MemPoolChunked:
Collaboration diagram for MemPoolChunked:

Public Member Functions

 MemPoolChunked (const char *label, size_t obj_size)
 ~MemPoolChunked ()
void convertFreeCacheToChunkFreeCache ()
virtual void clean (time_t maxage)
virtual int getStats (MemPoolStats *stats, int accumulate)
void createChunk ()
void * get ()
void push (void *obj)
virtual int getInUseCount ()
virtual void setChunkSize (size_t chunksize)
virtual bool idleTrigger (int shift) const
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 ()

Static Public Member Functions

static size_t RoundedSize (size_t minSize)

Public Attributes

size_t chunk_size
int chunk_capacity
int chunkCount
void * freeCache
Splay< MemChunk * > allChunks
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


class MemChunk

Detailed Description

Definition at line 21 of file PoolChunked.h.

Constructor & Destructor Documentation

MemPoolChunked::MemPoolChunked ( const char *  label,
size_t  obj_size 

Definition at line 138 of file PoolChunked.cc.

References M_MMAP_MAX, MEM_CHUNK_SIZE, MEM_MAX_MMAP_CHUNKS, and setChunkSize().

Referenced by getStats().

Member Function Documentation

void * MemImplementingAllocator::alloc ( )

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 * MemPoolChunked::allocate ( )
void MemPoolChunked::createChunk ( )

Definition at line 222 of file PoolChunked.cc.

References Chunks, MemChunk, MemChunk::next, NULL, and MemChunk::objCache.

Referenced by get().

void MemPoolChunked::deallocate ( void *  obj,
bool  aggressive 
void MemImplementingAllocator::freeOne ( void *  obj)
int MemPoolChunked::getInUseCount ( )
MemPoolMeter const & MemImplementingAllocator::getMeter ( ) const
MemPoolMeter & MemImplementingAllocator::getMeter ( )

Definition at line 355 of file Pool.cc.

References MemImplementingAllocator::meter.

bool MemPoolChunked::idleTrigger ( int  shift) const
int MemAllocator::inUseCount ( )

Definition at line 113 of file Pool.cc.

References MemAllocator::getInUseCount().

Referenced by memInUse(), and memStringCount().

size_t MemImplementingAllocator::objectSize ( ) const

Implements MemAllocator.

Definition at line 361 of file Pool.cc.

References MemImplementingAllocator::obj_size.

char const * MemAllocator::objectType ( ) const

Definition at line 107 of file Pool.cc.

References MemAllocator::label.

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

void MemPoolChunked::push ( void *  obj)
size_t MemAllocator::RoundedSize ( size_t  minSize)
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().

void MemPoolChunked::setChunkSize ( size_t  chunksize)

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.

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

Reimplemented from MemAllocator.

Definition at line 253 of file PoolChunked.cc.

References chunk_capacity, chunk_size, Chunks, MEM_CHUNK_MAX_SIZE, MEM_MAX_FREE, MEM_MIN_FREE, MEM_PAGE_SIZE, and MemImplementingAllocator::obj_size.

Referenced by MemPoolChunked().

void MemAllocator::zeroBlocks ( bool  doIt)

Definition at line 205 of file Pool.h.

References MemAllocator::doZero.

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

Friends And Related Function Documentation

friend class MemChunk

Definition at line 24 of file PoolChunked.h.

Referenced by createChunk().

Member Data Documentation

Splay<MemChunk *> MemPoolChunked::allChunks
size_t MemImplementingAllocator::alloc_calls
int MemPoolChunked::chunk_capacity
size_t MemPoolChunked::chunk_size

Definition at line 58 of file PoolChunked.h.

Referenced by MemChunk::MemChunk(), memCompObjChunks(), and setChunkSize().

int MemPoolChunked::chunkCount

Definition at line 60 of file PoolChunked.h.

Referenced by getStats(), MemChunk::MemChunk(), and MemChunk::~MemChunk().

MemChunk* MemPoolChunked::Chunks

Definition at line 63 of file PoolChunked.h.

Referenced by clean(), createChunk(), getStats(), setChunkSize(), and ~MemPoolChunked().

bool MemAllocator::doZero

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

size_t MemImplementingAllocator::free_calls
void* MemPoolChunked::freeCache

Definition at line 61 of file PoolChunked.h.

Referenced by convertFreeCacheToChunkFreeCache(), get(), and push().

int MemImplementingAllocator::memPID

Definition at line 268 of file Pool.h.

Referenced by MemImplementingAllocator::MemImplementingAllocator().

MemChunk* MemPoolChunked::nextFreeChunk

Definition at line 62 of file PoolChunked.h.

Referenced by clean(), get(), and MemChunk::MemChunk().

size_t MemImplementingAllocator::saved_calls

Definition at line 274 of file Pool.h.

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

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






Web Site Translations