#include <PoolMalloc.h>
Public Member Functions | |
MemPoolMalloc (char const *label, size_t aSize) | |
~MemPoolMalloc () override | |
size_t | getStats (Mem::PoolStats &) override |
bool | idleTrigger (int) const override |
void | clean (time_t) override |
void | relabel (const char *const aLabel) |
void * | alloc () |
provide (and reserve) memory suitable for storing one object More... | |
void | freeOne (void *obj) |
return memory reserved by alloc() More... | |
int | getInUseCount () const |
the difference between the number of alloc() and freeOne() calls More... | |
void | zeroBlocks (const bool doIt) |
virtual void | setChunkSize (size_t) |
XXX: Misplaced – not all allocators have a notion of a "chunk". See MemPoolChunked. More... | |
void | flushCounters () |
Static Public Member Functions | |
static size_t | RoundedSize (const size_t minSize) |
Public Attributes | |
size_t | countAlloc = 0 |
the number of calls to Mem::Allocator::alloc() since last flush More... | |
size_t | countSavedAllocs = 0 |
the number of malloc()/calloc() calls avoided since last flush More... | |
size_t | countFreeOne = 0 |
the number of calls to Mem::Allocator::freeOne() since last flush More... | |
const char * | label |
brief description of objects returned by alloc() More... | |
const size_t | objectSize |
the size (in bytes) of objects managed by this allocator More... | |
PoolMeter | meter |
statistics tracked for this allocator More... | |
Static Public Attributes | |
static const size_t | FlushLimit = 1000 |
Flush counters to 'meter' after flush limit allocations. More... | |
Protected Member Functions | |
void * | allocate () override |
*alloc() More... | |
void | deallocate (void *) override |
freeOne(void *) More... | |
Protected Attributes | |
bool | doZero = true |
Private Attributes | |
std::stack< void * > | freelist |
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 79 of file PoolMalloc.cc.
◆ ~MemPoolMalloc()
|
override |
Definition at line 84 of file PoolMalloc.cc.
References assert, clean(), and Mem::Allocator::getInUseCount().
Member Function Documentation
◆ alloc()
|
inlineinherited |
Definition at line 44 of file Allocator.h.
References Mem::Allocator::allocate(), Mem::Allocator::countAlloc, Mem::Allocator::flushCounters(), and Mem::Allocator::FlushLimit.
Referenced by Mem::AllocatorProxy::alloc(), authenticateDigestNonceNew(), cbdataInternalAlloc(), memAllocate(), squidaio_close(), squidaio_init(), squidaio_open(), squidaio_read(), squidaio_stat(), squidaio_unlink(), and squidaio_write().
◆ allocate()
|
overrideprotectedvirtual |
*alloc()
Implements Mem::Allocator.
Definition at line 24 of file PoolMalloc.cc.
References Mem::PoolMeter::alloc, Mem::Allocator::countSavedAllocs, Mem::Allocator::doZero, freelist, Mem::PoolMeter::idle, Mem::PoolMeter::inuse, Mem::Allocator::meter, Mem::Allocator::objectSize, xcalloc(), and xmalloc.
◆ clean()
|
overridevirtual |
Implements Mem::Allocator.
Definition at line 97 of file PoolMalloc.cc.
References Mem::PoolMeter::alloc, freelist, Mem::PoolMeter::idle, Mem::Allocator::meter, and xfree.
Referenced by ~MemPoolMalloc().
◆ deallocate()
|
overrideprotectedvirtual |
Implements Mem::Allocator.
Definition at line 46 of file PoolMalloc.cc.
References Mem::PoolMeter::alloc, Mem::Allocator::doZero, freelist, MemPools::GetInstance(), Mem::PoolMeter::idle, Mem::PoolMeter::inuse, Mem::Allocator::meter, Mem::Allocator::objectSize, and xfree.
◆ flushCounters()
|
inlineinherited |
Flush temporary counter values into the statistics held in 'meter'.
Definition at line 74 of file Allocator.h.
References Mem::Allocator::countAlloc, Mem::Allocator::countFreeOne, Mem::Allocator::countSavedAllocs, Mem::PoolMeter::gb_allocated, Mem::PoolMeter::gb_freed, Mem::PoolMeter::gb_saved, Mem::Allocator::meter, Mem::Allocator::objectSize, and Mem::PoolMeter::mgb_t::update().
Referenced by MemPoolChunked::~MemPoolChunked(), Mem::Allocator::alloc(), and MemPoolChunked::clean().
◆ freeOne()
|
inlineinherited |
Definition at line 51 of file Allocator.h.
References assert, Mem::Allocator::countFreeOne, Mem::Allocator::deallocate(), Mem::Allocator::objectSize, and VALGRIND_CHECK_MEM_IS_ADDRESSABLE.
Referenced by cbdata::~cbdata(), authenticateDigestNonceDelete(), memFree(), and squidaio_cleanup_request().
◆ getInUseCount()
|
inlineinherited |
Definition at line 59 of file Allocator.h.
References Mem::Meter::currentLevel(), Mem::PoolMeter::inuse, and Mem::Allocator::meter.
Referenced by MemPoolChunked::~MemPoolChunked(), ~MemPoolMalloc(), MemPoolChunked::getStats(), getStats(), StoreEntry::inUseCount(), memInUse(), and memStringCount().
◆ getStats()
|
overridevirtual |
fill the given object with statistical data about pool
- Returns
- Number of objects in use, ie. allocated.
Implements Mem::Allocator.
Definition at line 62 of file PoolMalloc.cc.
References Mem::PoolMeter::alloc, Mem::Meter::currentLevel(), Mem::Allocator::getInUseCount(), Mem::PoolMeter::idle, Mem::PoolMeter::inuse, Mem::Allocator::label, Mem::Allocator::meter, Mem::Allocator::objectSize, and Ping::stats.
◆ idleTrigger()
|
overridevirtual |
◆ relabel()
|
inlineinherited |
change the allocator description if we were only able to provide an approximate description at object construction time
Definition at line 34 of file Allocator.h.
References Mem::Allocator::label.
◆ RoundedSize()
- Parameters
-
minSize Minimum size needed to be allocated.
- Return values
-
n Smallest size divisible by sizeof(void*)
Definition at line 93 of file Allocator.h.
Referenced by GetStrPool().
◆ setChunkSize()
|
inlinevirtualinherited |
Reimplemented in MemPoolChunked.
Definition at line 65 of file Allocator.h.
Referenced by Mem::Init().
◆ zeroBlocks()
|
inlineinherited |
- See also
- doZero
Definition at line 62 of file Allocator.h.
References Mem::Allocator::doZero.
Referenced by Mem::AllocatorProxy::getAllocator(), GetStrPool(), and memDataInit().
Member Data Documentation
◆ countAlloc
|
inherited |
Definition at line 98 of file Allocator.h.
Referenced by Mem::Allocator::alloc(), and Mem::Allocator::flushCounters().
◆ countFreeOne
|
inherited |
Definition at line 104 of file Allocator.h.
Referenced by Mem::Allocator::flushCounters(), and Mem::Allocator::freeOne().
◆ countSavedAllocs
|
inherited |
Definition at line 101 of file Allocator.h.
Referenced by allocate(), Mem::Allocator::flushCounters(), and MemPoolChunked::get().
◆ 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. When possible, set this to false to avoid zeroing overheads.
Definition at line 130 of file Allocator.h.
Referenced by MemChunk::MemChunk(), allocate(), deallocate(), MemPoolChunked::push(), and Mem::Allocator::zeroBlocks().
◆ FlushLimit
|
staticinherited |
Definition at line 25 of file Allocator.h.
Referenced by Mem::Allocator::alloc().
◆ freelist
|
private |
Definition at line 53 of file PoolMalloc.h.
Referenced by allocate(), clean(), deallocate(), and idleTrigger().
◆ label
|
inherited |
Definition at line 109 of file Allocator.h.
Referenced by MemPoolChunked::getStats(), getStats(), and Mem::Allocator::relabel().
◆ meter
|
inherited |
Definition at line 115 of file Allocator.h.
Referenced by MemChunk::MemChunk(), MemChunk::~MemChunk(), MemPoolChunked::allocate(), allocate(), clean(), MemPoolChunked::deallocate(), deallocate(), Mem::Allocator::flushCounters(), Mem::Allocator::getInUseCount(), MemPoolChunked::getStats(), getStats(), MemPoolChunked::idleTrigger(), and Mem::Report().
◆ objectSize
|
inherited |
Definition at line 112 of file Allocator.h.
Referenced by MemChunk::MemChunk(), allocate(), deallocate(), Mem::Allocator::flushCounters(), Mem::Allocator::freeOne(), MemPoolChunked::get(), MemPoolChunked::getStats(), getStats(), MemPoolChunked::push(), and MemPoolChunked::setChunkSize().
The documentation for this class was generated from the following files:
- src/mem/PoolMalloc.h
- src/mem/PoolMalloc.cc