Memory Management (Memory Pool Allocator)
[Squid Components]

Collaboration diagram for Memory Management (Memory Pool Allocator):

Classes

class  MemPoolIterator
class  mgb_t
class  MemPoolMeter
class  MemPools
class  MemAllocator
class  MemAllocatorProxy
class  MemImplementingAllocator
class  MemPoolStats
struct  _MemPoolGlobalStats
class  MemPoolChunked
class  MemChunk
class  MemPoolMalloc

Defines

#define MB   ((size_t)1024*1024)
#define toMB(size)   ( ((double) size) / MB )
#define toKB(size)   ( (size + 1024 - 1) / 1024 )
#define MEM_PAGE_SIZE   4096
#define MEM_CHUNK_SIZE   4096 * 4
#define MEM_CHUNK_MAX_SIZE   256 * 1024
#define MEM_MIN_FREE   32
#define MEM_MAX_FREE   65535
#define MEMPROXY_CLASS(CLASS)
#define MEMPROXY_CLASS_INLINE(CLASS)
#define memPoolCreate   MemPools::GetInstance().create
#define MEM_PAGE_SIZE   4096
#define MEM_CHUNK_SIZE   4096 * 4
#define MEM_CHUNK_MAX_SIZE   256 * 1024
#define MEM_MIN_FREE   32
#define MEM_MAX_FREE   65535

Typedefs

typedef struct _MemPoolGlobalStats MemPoolGlobalStats

Functions

MemPoolIteratormemPoolIterate (void)
MemImplementingAllocatormemPoolIterateNext (MemPoolIterator *iter)
void memPoolIterateDone (MemPoolIterator **iter)
int memPoolGetGlobalStats (MemPoolGlobalStats *stats)
int memPoolInUseCount (MemAllocator *)
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.

Define Documentation

#define MB   ((size_t)1024*1024)

Definition at line 46 of file MemPool.h.

#define MEM_CHUNK_MAX_SIZE   256 * 1024

Definition at line 11 of file MemPoolChunked.h.

#define MEM_CHUNK_MAX_SIZE   256 * 1024

Definition at line 57 of file MemPool.h.

Referenced by MemPoolChunked::setChunkSize().

#define MEM_CHUNK_SIZE   4096 * 4

Definition at line 9 of file MemPoolChunked.h.

#define MEM_CHUNK_SIZE   4096 * 4

Definition at line 55 of file MemPool.h.

Referenced by MemPoolChunked::MemPoolChunked().

#define MEM_MAX_FREE   65535

Definition at line 15 of file MemPoolChunked.h.

#define MEM_MAX_FREE   65535

Definition at line 61 of file MemPool.h.

Referenced by MemPoolChunked::setChunkSize().

#define MEM_MIN_FREE   32

Definition at line 13 of file MemPoolChunked.h.

#define MEM_MIN_FREE   32

Definition at line 59 of file MemPool.h.

Referenced by MemPoolChunked::setChunkSize().

#define MEM_PAGE_SIZE   4096

Definition at line 7 of file MemPoolChunked.h.

#define MEM_PAGE_SIZE   4096

Definition at line 53 of file MemPool.h.

Referenced by MemPoolChunked::setChunkSize().

#define MEMPROXY_CLASS ( CLASS   ) 

This macro is intended for use within the declaration of a class.

Definition at line 282 of file MemPool.h.

#define MEMPROXY_CLASS_INLINE ( CLASS   ) 

This macro is intended for use within the .h or .cci of a class as appropriate.

Definition at line 293 of file MemPool.h.

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

Definition at line 50 of file MemPool.h.

Referenced by Mem::PoolReport().

#define toMB ( size   )     ( ((double) size) / MB )

Definition at line 48 of file MemPool.h.

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


Typedef Documentation

Todo:
Kill this typedef for C++

Definition at line 68 of file MemPool.h.


Function Documentation

int memPoolInUseCount ( MemAllocator  ) 

Definition at line 339 of file MemPool.cc.

References MemAllocator::inUseCount().

Referenced by MemAllocatorProxy::inUseCount(), memInUse(), and memStringCount().

MemPoolIterator* memPoolIterate ( void   ) 

Initialise iteration through all of the pools.

Return values:
Iterator for use by memPoolIterateNext() and memPoolIterateDone()

Definition at line 77 of file MemPool.cc.

References MemPools::GetInstance(), 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 84 of file MemPool.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 92 of file MemPool.cc.

References assert, MemImplementingAllocator::next, NULL, MemPoolIterator::pool, and pool.

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

int memPoolsTotalAllocated ( void   ) 

Search

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors