Memory Management (Memory Pool Allocator)
Collaboration diagram for Memory Management (Memory Pool Allocator):

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

MemPoolIteratormemPoolIterate (void)
 
MemImplementingAllocatormemPoolIterateNext (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

#define MEM_MAX_FREE   65535 /* unsigned short is max number of items per chunk */

Definition at line 59 of file Pool.h.

Referenced by MemPoolChunked::setChunkSize().

#define MEM_MIN_FREE   32

Definition at line 57 of file Pool.h.

Referenced by MemPoolChunked::setChunkSize().

#define MEM_PAGE_SIZE   4096

Definition at line 55 of file Pool.h.

Referenced by MemPoolChunked::setChunkSize().

#define memPoolCreate   MemPools::GetInstance().create

Creates a named MemPool of elements with the given size

Definition at line 325 of file Pool.h.

Referenced by authenticateDigestNonceSetup(), cbdataInternalInitType(), createRemovalPolicy_lru(), GetStrPool(), memDataInit(), StoreEntry::operator new(), squidaio_init(), and testMem::testMemPool().

#define toKB (   size)    ( (size + 1024 - 1) / 1024 )

Definition at line 52 of file Pool.h.

Referenced by Mem::PoolReport().

#define toMB (   size)    ( ((double) size) / ((double)(1024*1024)) )

Definition at line 50 of file Pool.h.

Referenced by memConfigure(), and Mem::Report().

Typedef Documentation

Todo:
Kill this typedef for C++

Definition at line 66 of file Pool.h.

Function Documentation

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

void memPoolIterateDone ( MemPoolIterator **  iter)

Should be called after finished with iterating through all pools.

Definition at line 47 of file Pool.cc.

References assert, NULL, and MemPoolIterator::pool.

Referenced by MemPools::clean(), MemPools::flushMeters(), memPoolGetGlobalStats(), and Mem::Report().

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

int memPoolsTotalAllocated ( void  )

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors