#include <Pool.h>

Public Member Functions | |
MemPools () | |
void | flushMeters () |
MemImplementingAllocator * | create (const char *label, size_t obj_size) |
void | setIdleLimit (ssize_t new_idle_limit) |
ssize_t | idleLimit () const |
void | clean (time_t maxage) |
void | setDefaultPoolChunking (bool const &) |
Static Public Member Functions | |
static MemPools & | GetInstance () |
Public Attributes | |
MemImplementingAllocator * | pools = nullptr |
ssize_t | mem_idle_limit = (2 << 20) |
int | poolCount = 0 |
bool | defaultIsChunked = false |
Detailed Description
Constructor & Destructor Documentation
◆ MemPools()
MemPools::MemPools | ( | ) |
Member Function Documentation
◆ clean()
void MemPools::clean | ( | time_t | maxage | ) |
- Main cleanup handler. For MemPools to stay within upper idle limits, this function needs to be called periodically, preferably at some constant rate, eg. from Squid event. It looks through all pools and chunks, cleans up internal states and checks for releasable chunks.
- Between the calls to this function objects are placed onto internal cache instead of returning to their home chunks, mainly for speedup purpose. During that time state of chunk is not known, it is not known whether chunk is free or in use. This call returns all objects to their chunks and restores consistency.
- Should be called relatively often, as it sorts chunks in suitable order as to reduce free memory fragmentation and increase chunk utilisation. Suitable frequency for cleanup is in range of few tens of seconds to few minutes, depending of memory activity.
TODO: DOCS: Re-write this shorter!
- Parameters
-
maxage Release all totally idle chunks that have not been referenced for maxage seconds.
Definition at line 223 of file Pool.cc.
References MemImplementingAllocator::clean(), Mem::Meter::currentLevel(), flushMeters(), MemPoolMeter::idle, MemImplementingAllocator::idleTrigger(), mem_idle_limit, memPoolIterate(), memPoolIterateDone(), memPoolIterateNext(), and TheMeter.
Referenced by Mem::CleanIdlePools(), and memClean().
◆ create()
MemImplementingAllocator * MemPools::create | ( | const char * | label, |
size_t | obj_size | ||
) |
- Parameters
-
label Name for the pool. Displayed in stats. obj_size Size of elements in MemPool.
Definition at line 90 of file Pool.cc.
References defaultIsChunked, and poolCount.
Referenced by Mem::AllocatorProxy::getAllocator().
◆ flushMeters()
void MemPools::flushMeters | ( | ) |
Definition at line 173 of file Pool.cc.
References MemPoolMeter::alloc, mgb_t::bytes, mgb_t::count, Mem::Meter::currentLevel(), MemPoolMeter::flush(), MemPoolMeter::gb_allocated, MemPoolMeter::gb_freed, MemPoolMeter::gb_saved, MemPoolMeter::idle, MemPoolMeter::inuse, memPoolIterate(), memPoolIterateDone(), memPoolIterateNext(), and TheMeter.
Referenced by clean(), and memPoolGetGlobalStats().
◆ GetInstance()
|
static |
Definition at line 29 of file Pool.cc.
References MemPools(), and Instance().
Referenced by MemImplementingAllocator::MemImplementingAllocator(), MemImplementingAllocator::~MemImplementingAllocator(), Mem::CleanIdlePools(), MemImplementingAllocator::freeOne(), Mem::AllocatorProxy::getAllocator(), memClean(), memConfigure(), memPoolGetGlobalStats(), memPoolIterate(), and Mem::Report().
◆ idleLimit()
ssize_t MemPools::idleLimit | ( | ) | const |
Definition at line 74 of file Pool.cc.
References mem_idle_limit.
◆ setDefaultPoolChunking()
void MemPools::setDefaultPoolChunking | ( | bool const & | aBool | ) |
Definition at line 100 of file Pool.cc.
References defaultIsChunked.
◆ setIdleLimit()
void MemPools::setIdleLimit | ( | ssize_t | new_idle_limit | ) |
Sets upper limit in bytes to amount of free ram kept in pools. This is not strict upper limit, but a hint. When MemPools are over this limit, totally free chunks are immediately considered for release. Otherwise only chunks that have not been referenced for a long time are checked.
Definition at line 68 of file Pool.cc.
References mem_idle_limit.
Referenced by memClean(), and memConfigure().
Member Data Documentation
◆ defaultIsChunked
bool MemPools::defaultIsChunked = false |
Definition at line 171 of file Pool.h.
Referenced by MemPools(), create(), and setDefaultPoolChunking().
◆ mem_idle_limit
ssize_t MemPools::mem_idle_limit = (2 << 20) |
Definition at line 169 of file Pool.h.
Referenced by clean(), idleLimit(), memPoolGetGlobalStats(), and setIdleLimit().
◆ poolCount
int MemPools::poolCount = 0 |
Definition at line 170 of file Pool.h.
Referenced by MemImplementingAllocator::~MemImplementingAllocator(), create(), and memPoolGetGlobalStats().
◆ pools
MemImplementingAllocator* MemPools::pools = nullptr |
Definition at line 168 of file Pool.h.
Referenced by MemImplementingAllocator::MemImplementingAllocator(), MemImplementingAllocator::~MemImplementingAllocator(), and memPoolIterate().
The documentation for this class was generated from the following files:
- src/mem/Pool.h
- src/mem/Pool.cc
- src/tests/stub_libmem.cc