#include <PoolMalloc.h>


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 MemPoolMeter & | getMeter () |
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 | |
MemImplementingAllocator * | next |
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 |
const char * | label |
Detailed Description
Definition at line 36 of file PoolMalloc.h.
Constructor & Destructor Documentation
◆ MemPoolMalloc()
MemPoolMalloc::MemPoolMalloc | ( | char const * | label, |
size_t | aSize | ||
) |
Definition at line 91 of file PoolMalloc.cc.
Referenced by getStats().
◆ ~MemPoolMalloc()
MemPoolMalloc::~MemPoolMalloc | ( | ) |
Definition at line 95 of file PoolMalloc.cc.
References assert, clean(), Mem::Meter::currentLevel(), MemPoolMeter::inuse, and MemImplementingAllocator::meter.
Member Function Documentation
◆ alloc()
|
virtualinherited |
Allocate one element from the pool
Implements MemAllocator.
Definition at line 196 of file Pool.cc.
References MemImplementingAllocator::alloc_calls, MemImplementingAllocator::allocate(), FLUSH_LIMIT, and MemImplementingAllocator::flushMeters().
◆ allocate()
|
protectedvirtual |
Implements MemImplementingAllocator.
Definition at line 22 of file PoolMalloc.cc.
References MemPoolMeter::alloc, MemAllocator::doZero, freelist, MemPoolMeter::idle, MemPoolMeter::inuse, MemImplementingAllocator::meter, NULL, MemImplementingAllocator::obj_size, MemImplementingAllocator::saved_calls, xcalloc(), and xmalloc.
◆ clean()
|
virtual |
Implements MemImplementingAllocator.
Definition at line 108 of file PoolMalloc.cc.
References MemPoolMeter::alloc, freelist, MemPoolMeter::idle, MemImplementingAllocator::meter, and xfree.
Referenced by ~MemPoolMalloc().
◆ deallocate()
|
protectedvirtual |
Implements MemImplementingAllocator.
Definition at line 44 of file PoolMalloc.cc.
References MemPoolMeter::alloc, MemAllocator::doZero, freelist, MemPoolMeter::idle, MemPoolMeter::inuse, MemImplementingAllocator::meter, MemImplementingAllocator::obj_size, and xfree.
◆ flushMeters()
|
virtualinherited |
Definition at line 118 of file Pool.cc.
References MemImplementingAllocator::alloc_calls, mgb_t::count, MemImplementingAllocator::free_calls, MemPoolMeter::gb_allocated, MemPoolMeter::gb_freed, MemPoolMeter::gb_saved, MemImplementingAllocator::meter, and MemImplementingAllocator::saved_calls.
Referenced by MemImplementingAllocator::alloc(), and MemImplementingAllocator::flushMetersFull().
◆ flushMetersFull()
|
virtualinherited |
Definition at line 140 of file Pool.cc.
References mgb_t::bytes, mgb_t::count, MemImplementingAllocator::flushMeters(), MemPoolMeter::gb_allocated, MemPoolMeter::gb_freed, MemPoolMeter::gb_saved, MemImplementingAllocator::getMeter(), and MemImplementingAllocator::obj_size.
Referenced by MemPoolChunked::~MemPoolChunked(), and MemPoolChunked::clean().
◆ freeOne()
|
virtualinherited |
Free a element allocated by MemImplementingAllocator::alloc()
Implements MemAllocator.
Definition at line 205 of file Pool.cc.
References assert, MemImplementingAllocator::deallocate(), MemImplementingAllocator::free_calls, MemPools::GetInstance(), NULL, MemImplementingAllocator::obj_size, and VALGRIND_CHECK_MEM_IS_ADDRESSABLE.
◆ getInUseCount()
|
virtual |
Implements MemImplementingAllocator.
Definition at line 86 of file PoolMalloc.cc.
References Mem::Meter::currentLevel(), MemPoolMeter::inuse, and MemImplementingAllocator::meter.
◆ getMeter() [1/2]
|
virtualinherited |
Definition at line 354 of file Pool.cc.
References MemImplementingAllocator::meter.
◆ getMeter() [2/2]
|
virtualinherited |
Implements MemAllocator.
Definition at line 348 of file Pool.cc.
References MemImplementingAllocator::meter.
Referenced by MemChunk::MemChunk(), MemChunk::~MemChunk(), and MemImplementingAllocator::flushMetersFull().
◆ getStats()
|
virtual |
- Parameters
-
stats Object to be filled with statistical data about pool.
- Return values
-
Number of objects in use, ie. allocated.
Implements MemAllocator.
Definition at line 60 of file PoolMalloc.cc.
References MemPoolMalloc(), MemPoolMeter::alloc, Mem::Meter::currentLevel(), MemPoolMeter::idle, MemPoolMeter::inuse, MemImplementingAllocator::meter, MemImplementingAllocator::obj_size, MemAllocator::objectType(), and Ping::stats.
◆ idleTrigger()
|
virtual |
Implements MemImplementingAllocator.
Definition at line 102 of file PoolMalloc.cc.
References freelist.
◆ inUseCount()
|
inherited |
Definition at line 112 of file Pool.cc.
References MemAllocator::getInUseCount().
Referenced by memInUse(), and memStringCount().
◆ objectSize()
|
virtualinherited |
Implements MemAllocator.
Definition at line 360 of file Pool.cc.
References MemImplementingAllocator::obj_size.
◆ objectType()
|
virtualinherited |
Definition at line 106 of file Pool.cc.
References MemAllocator::label.
Referenced by cbdataDump(), MemPoolChunked::getStats(), and getStats().
◆ RoundedSize()
- Parameters
-
minSize Minimum size needed to be allocated.
- Return values
-
n Smallest size divisible by sizeof(void*)
Definition at line 292 of file Pool.cc.
Referenced by GetStrPool().
◆ setChunkSize()
|
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().
◆ zeroBlocks()
|
inlineinherited |
Definition at line 205 of file Pool.h.
References MemAllocator::doZero.
Referenced by Mem::AllocatorProxy::getAllocator(), GetStrPool(), and memDataInit().
Member Data Documentation
◆ alloc_calls
|
inherited |
Definition at line 272 of file Pool.h.
Referenced by MemImplementingAllocator::alloc(), and MemImplementingAllocator::flushMeters().
◆ 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 MemChunk::MemChunk(), allocate(), deallocate(), MemPoolChunked::push(), and MemAllocator::zeroBlocks().
◆ free_calls
|
inherited |
Definition at line 273 of file Pool.h.
Referenced by MemImplementingAllocator::flushMeters(), and MemImplementingAllocator::freeOne().
◆ freelist
|
private |
Definition at line 55 of file PoolMalloc.h.
Referenced by allocate(), clean(), deallocate(), and idleTrigger().
◆ label
|
privateinherited |
Definition at line 236 of file Pool.h.
Referenced by MemAllocator::objectType().
◆ memPID
|
protectedinherited |
Definition at line 268 of file Pool.h.
Referenced by MemImplementingAllocator::MemImplementingAllocator().
◆ meter
|
protectedinherited |
Definition at line 267 of file Pool.h.
Referenced by MemPoolChunked::~MemPoolChunked(), ~MemPoolMalloc(), MemPoolChunked::allocate(), allocate(), clean(), MemPoolChunked::deallocate(), deallocate(), MemImplementingAllocator::flushMeters(), MemPoolChunked::getInUseCount(), getInUseCount(), MemImplementingAllocator::getMeter(), MemPoolChunked::getStats(), getStats(), and MemPoolChunked::idleTrigger().
◆ next
|
inherited |
Definition at line 270 of file Pool.h.
Referenced by MemImplementingAllocator::MemImplementingAllocator(), MemImplementingAllocator::~MemImplementingAllocator(), and memPoolIterateNext().
◆ obj_size
|
inherited |
Definition at line 275 of file Pool.h.
Referenced by MemChunk::MemChunk(), allocate(), deallocate(), MemImplementingAllocator::flushMetersFull(), MemImplementingAllocator::freeOne(), MemPoolChunked::get(), MemPoolChunked::getStats(), getStats(), MemImplementingAllocator::objectSize(), MemPoolChunked::push(), and MemPoolChunked::setChunkSize().
◆ 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:
- src/mem/PoolMalloc.h
- src/mem/PoolMalloc.cc