#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
 
MemChunknextFreeChunk
 
MemChunkChunks
 
Splay< MemChunk * > allChunks
 
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
 

Friends

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

Allocate one element from the pool

Implements MemAllocator.

Definition at line 197 of file Pool.cc.

References FLUSH_LIMIT, and MemPools::flushMeters().

◆ allocate()

void * MemPoolChunked::allocate ( )
protectedvirtual

◆ 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 
)
protectedvirtual

◆ flushMeters()

void MemImplementingAllocator::flushMeters ( )
virtualinherited

Definition at line 119 of file Pool.cc.

◆ flushMetersFull()

void MemImplementingAllocator::flushMetersFull ( )
virtualinherited

Definition at line 141 of file Pool.cc.

References MemPools::flushMeters().

Referenced by clean(), and ~MemPoolChunked().

◆ freeOne()

void MemImplementingAllocator::freeOne ( void *  obj)
virtualinherited

Free a element allocated by MemImplementingAllocator::alloc()

Implements MemAllocator.

Definition at line 206 of file Pool.cc.

References assert, MemPools::GetInstance(), MemPools::mem_idle_limit, NULL, and VALGRIND_CHECK_MEM_IS_ADDRESSABLE.

◆ get()

◆ getInUseCount()

int MemPoolChunked::getInUseCount ( )
virtual

◆ getMeter() [1/2]

MemPoolMeter const & MemImplementingAllocator::getMeter ( ) const
virtualinherited

Implements MemAllocator.

Definition at line 349 of file Pool.cc.

References MemImplementingAllocator::meter.

Referenced by MemChunk::MemChunk().

◆ getMeter() [2/2]

MemPoolMeter & MemImplementingAllocator::getMeter ( )
virtualinherited

Definition at line 355 of file Pool.cc.

References MemImplementingAllocator::meter.

◆ getStats()

◆ idleTrigger()

bool MemPoolChunked::idleTrigger ( int  shift) const
virtual

◆ inUseCount()

int MemAllocator::inUseCount ( )
inherited

Definition at line 113 of file Pool.cc.

Referenced by Mem::AllocatorProxy::inUseCount(), memInUse(), and memStringCount().

◆ objectSize()

size_t MemImplementingAllocator::objectSize ( ) const
virtualinherited

Implements MemAllocator.

Definition at line 361 of file Pool.cc.

References MemImplementingAllocator::obj_size.

◆ objectType()

char const * MemAllocator::objectType ( ) const
virtualinherited

Definition at line 107 of file Pool.cc.

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

◆ push()

void MemPoolChunked::push ( void *  obj)

◆ RoundedSize()

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

◆ setChunkSize()

void MemPoolChunked::setChunkSize ( size_t  chunksize)
virtual

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

Friends And Related Function Documentation

◆ MemChunk

friend class MemChunk
friend

Definition at line 24 of file PoolChunked.h.

Referenced by createChunk().

Member Data Documentation

◆ allChunks

Splay<MemChunk *> MemPoolChunked::allChunks

Definition at line 64 of file PoolChunked.h.

Referenced by convertFreeCacheToChunkFreeCache(), and MemChunk::MemChunk().

◆ alloc_calls

size_t MemImplementingAllocator::alloc_calls
inherited

Definition at line 272 of file Pool.h.

◆ chunk_capacity

int MemPoolChunked::chunk_capacity

Definition at line 59 of file PoolChunked.h.

Referenced by clean(), getStats(), idleTrigger(), MemChunk::MemChunk(), and setChunkSize().

◆ 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(), 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
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 MemPoolMalloc::allocate(), MemPoolMalloc::deallocate(), MemChunk::MemChunk(), and push().

◆ free_calls

size_t MemImplementingAllocator::free_calls
inherited

Definition at line 273 of file Pool.h.

◆ freeCache

void* MemPoolChunked::freeCache

Definition at line 61 of file PoolChunked.h.

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

◆ memPID

int MemImplementingAllocator::memPID
protectedinherited

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
inherited

Definition at line 274 of file Pool.h.

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


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors