
Classes | |
class | MemPoolIterator |
class | mgb_t |
class | MemPoolMeter |
class | MemPools |
class | MemAllocator |
class | MemImplementingAllocator |
class | MemPoolStats |
struct | _MemPoolGlobalStats |
class | MemPoolChunked |
class | MemChunk |
class | MemPoolMalloc |
Macros | |
#define | toMB(size) ( ((double) size) / ((double)(1024*1024)) ) |
#define | toKB(size) ( (size + 1024 - 1) / 1024 ) |
#define | MEM_PAGE_SIZE 4096 |
#define | MEM_MIN_FREE 32 |
#define | MEM_MAX_FREE 65535 /* unsigned short is max number of items per chunk */ |
#define | memPoolCreate MemPools::GetInstance().create |
Typedefs | |
typedef struct _MemPoolGlobalStats | MemPoolGlobalStats |
Functions | |
MemPoolIterator * | memPoolIterate (void) |
MemImplementingAllocator * | memPoolIterateNext (MemPoolIterator *iter) |
void | memPoolIterateDone (MemPoolIterator **iter) |
int | memPoolGetGlobalStats (MemPoolGlobalStats *stats) |
int | memPoolsTotalAllocated (void) |
Detailed Description
- MemPools are a pooled memory allocator running on top of malloc(). It's purpose is to reduce memory fragmentation and provide detailed statistics on memory consumption.
- Preferably all memory allocations in Squid should be done using MemPools or one of the types built on top of it (i.e. cbdata).
- Note
- Usually it is better to use cbdata types as these gives you additional safeguards in references and typechecking. However, for high usage pools where the cbdata functionality of cbdata is not required directly using a MemPool might be the way to go.
Macro Definition Documentation
◆ MEM_MAX_FREE
◆ MEM_MIN_FREE
◆ MEM_PAGE_SIZE
◆ memPoolCreate
#define memPoolCreate MemPools::GetInstance().create |
◆ toKB
◆ toMB
Typedef Documentation
◆ MemPoolGlobalStats
typedef struct _MemPoolGlobalStats MemPoolGlobalStats |
Function Documentation
◆ memPoolGetGlobalStats()
int memPoolGetGlobalStats | ( | MemPoolGlobalStats * | stats | ) |
Fills a MemPoolGlobalStats with statistical data about overall usage for all pools.
- Parameters
-
stats Object to be filled with statistical data.
- Returns
- Number of pools that have at least one object in use. Ie. number of dirty pools.
Definition at line 250 of file Pool.cc.
References MemPoolStats::chunks_alloc, MemPoolStats::chunks_free, MemPoolStats::chunks_inuse, MemPoolStats::chunks_partial, MemPools::flushMeters(), MemPools::GetInstance(), MemAllocator::getStats(), MemPoolStats::items_alloc, MemPoolStats::items_idle, MemPoolStats::items_inuse, MemPools::mem_idle_limit, memPoolIterate(), memPoolIterateDone(), memPoolIterateNext(), MemPoolStats::overhead, Pool_id_counter, MemPools::poolCount, pp_stats, Ping::stats, and TheMeter.
Referenced by DumpInfo(), GetInfo(), memClean(), memPoolsTotalAllocated(), and Mem::Report().
◆ memPoolIterate()
MemPoolIterator* memPoolIterate | ( | void | ) |
Initialise iteration through all of the pools.
- Returns
- Iterator for use by memPoolIterateNext() and memPoolIterateDone()
Definition at line 40 of file Pool.cc.
References MemPools::GetInstance(), Iterator, MemPoolIterator::pool, and MemPools::pools.
Referenced by MemPools::clean(), MemPools::flushMeters(), memPoolGetGlobalStats(), and Mem::Report().
◆ memPoolIterateDone()
void memPoolIterateDone | ( | MemPoolIterator ** | iter | ) |
Should be called after finished with iterating through all pools.
Definition at line 47 of file Pool.cc.
References assert, Iterator, NULL, and MemPoolIterator::pool.
Referenced by MemPools::clean(), MemPools::flushMeters(), memPoolGetGlobalStats(), and Mem::Report().
◆ memPoolIterateNext()
MemImplementingAllocator* memPoolIterateNext | ( | MemPoolIterator * | iter | ) |
Get next pool pointer, until getting NULL pointer.
Definition at line 55 of file Pool.cc.
References assert, MemImplementingAllocator::next, NULL, and MemPoolIterator::pool.
Referenced by MemPools::clean(), MemPools::flushMeters(), memPoolGetGlobalStats(), and Mem::Report().
◆ memPoolsTotalAllocated()
int memPoolsTotalAllocated | ( | void | ) |
Definition at line 299 of file Pool.cc.
References memPoolGetGlobalStats(), and Ping::stats.
Referenced by statMemoryAccounted().