#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 const MemPoolMetergetMeter () const
virtual MemPoolMetergetMeter ()
virtual void flushMetersFull ()
virtual void flushMeters ()
virtual void * alloc ()
virtual void freeOne (void *)
virtual size_t objectSize () const
virtual const char * 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

Private Attributes

const char * label


class MemChunk

Detailed Description

Definition at line 21 of file PoolChunked.h.

Constructor & Destructor Documentation

◆ MemPoolChunked()

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().

◆ ~MemPoolChunked()

Member Function Documentation

◆ alloc()

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().

◆ allocate()

void * MemPoolChunked::allocate ( )

◆ clean()

◆ convertFreeCacheToChunkFreeCache()

◆ createChunk()

void MemPoolChunked::createChunk ( )

Definition at line 222 of file PoolChunked.cc.

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

Referenced by get().

◆ deallocate()

void MemPoolChunked::deallocate ( void *  obj,
bool  aggressive 

◆ flushMeters()

◆ flushMetersFull()

◆ freeOne()

void MemImplementingAllocator::freeOne ( void *  obj)

◆ get()

◆ getInUseCount()

int MemPoolChunked::getInUseCount ( )

◆ getMeter() [1/2]

virtual MemPoolMeter& MemImplementingAllocator::getMeter ( )

◆ getMeter() [2/2]

MemPoolMeter & MemImplementingAllocator::getMeter ( ) const

◆ getStats()

int MemPoolChunked::getStats ( MemPoolStats stats,
int  accumulate 
statsObject to be filled with statistical data about pool.
Return values
Numberof objects in use, ie. allocated.

Implements MemAllocator.

Definition at line 427 of file PoolChunked.cc.

References MemPoolMeter::alloc, chunk_capacity, chunkCount, Chunks, clean(), Mem::Meter::currentLevel(), MemPoolMeter::idle, MemPoolMeter::inuse, MemChunk::inuse_count, MemPoolChunked(), MemImplementingAllocator::meter, MemChunk::next, MemImplementingAllocator::obj_size, MemAllocator::objectType(), and Ping::stats.

◆ idleTrigger()

bool MemPoolChunked::idleTrigger ( int  shift) const

◆ inUseCount()

int MemAllocator::inUseCount ( )

Definition at line 113 of file Pool.cc.

References MemAllocator::getInUseCount().

Referenced by memInUse(), and memStringCount().

◆ objectSize()

size_t MemImplementingAllocator::objectSize ( ) const

Implements MemAllocator.

Definition at line 361 of file Pool.cc.

References MemImplementingAllocator::obj_size.

◆ objectType()

const char * MemAllocator::objectType ( ) const

Definition at line 107 of file Pool.cc.

References MemAllocator::label.

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

◆ push()

void MemPoolChunked::push ( void *  obj)

◆ RoundedSize()

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().

◆ setChunkSize()

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().

◆ zeroBlocks()

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

◆ MemChunk

friend class MemChunk

Definition at line 24 of file PoolChunked.h.

Referenced by createChunk().

Member Data Documentation

◆ allChunks

Splay<MemChunk *> MemPoolChunked::allChunks

◆ alloc_calls

size_t MemImplementingAllocator::alloc_calls

◆ chunk_capacity

int MemPoolChunked::chunk_capacity

◆ chunk_size

size_t MemPoolChunked::chunk_size

Definition at line 58 of file PoolChunked.h.

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

◆ chunkCount

int MemPoolChunked::chunkCount

Definition at line 60 of file PoolChunked.h.

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

◆ Chunks

MemChunk* MemPoolChunked::Chunks

Definition at line 63 of file PoolChunked.h.

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

◆ doZero

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().

◆ free_calls

size_t MemImplementingAllocator::free_calls

◆ freeCache

void* MemPoolChunked::freeCache

Definition at line 61 of file PoolChunked.h.

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

◆ label

const char* MemAllocator::label

Definition at line 236 of file Pool.h.

Referenced by MemAllocator::objectType().

◆ memPID

int MemImplementingAllocator::memPID

Definition at line 268 of file Pool.h.

Referenced by MemImplementingAllocator::MemImplementingAllocator().

◆ meter

◆ next

◆ nextFreeChunk

MemChunk* MemPoolChunked::nextFreeChunk

Definition at line 62 of file PoolChunked.h.

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

◆ obj_size

◆ saved_calls

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