9#ifndef SQUID_SRC_MEM_ALLOCATOR_H
10#define SQUID_SRC_MEM_ALLOCATOR_H
13#include "mem/forward.h"
27 Allocator(
const char *
const aLabel,
const size_t sz):
69 virtual void clean(time_t maxage) = 0;
93 static size_t RoundedSize(
const size_t minSize) {
return ((minSize +
sizeof(
void*) - 1) /
sizeof(
void*)) *
sizeof(
void*); }
const size_t objectSize
the size (in bytes) of objects managed by this allocator
static size_t RoundedSize(const size_t minSize)
static const size_t FlushLimit
Flush counters to 'meter' after flush limit allocations.
virtual void deallocate(void *)=0
freeOne(void *)
size_t countFreeOne
the number of calls to Mem::Allocator::freeOne() since last flush
int getInUseCount() const
the difference between the number of alloc() and freeOne() calls
virtual size_t getStats(PoolStats &)=0
virtual void setChunkSize(size_t)
XXX: Misplaced – not all allocators have a notion of a "chunk". See MemPoolChunked.
Allocator(const char *const aLabel, const size_t sz)
const char * label
brief description of objects returned by alloc()
void relabel(const char *const aLabel)
virtual void clean(time_t maxage)=0
void freeOne(void *obj)
return memory reserved by alloc()
virtual bool idleTrigger(int shift) const =0
void zeroBlocks(const bool doIt)
void * alloc()
provide (and reserve) memory suitable for storing one object
virtual void * allocate()=0
*alloc()
size_t countAlloc
the number of calls to Mem::Allocator::alloc() since last flush
PoolMeter meter
statistics tracked for this allocator
size_t countSavedAllocs
the number of malloc()/calloc() calls avoided since last flush
ssize_t currentLevel() const
void update(size_t items, size_t itemSize)
account for memory actions taking place
convenience base for any class with pure virtual method(s)
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE