63 static bool initialized =
false;
66 memset(pools,
'\0',
sizeof(pools));
82 stream <<
"Large buffers: " <<
87 if (RUNNING_ON_VALGRIND) {
88 long int leaked = 0, dubious = 0, reachable = 0, suppressed = 0;
89 stream <<
"Valgrind Report:\n";
90 stream <<
"Type\tAmount\n";
92 VALGRIND_DO_LEAK_CHECK;
94 VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed);
95 stream <<
"Leaked\t" << leaked <<
"\n";
96 stream <<
"Dubious\t" << dubious <<
"\n";
97 stream <<
"Reachable\t" << reachable <<
"\n";
98 stream <<
"Suppressed\t" << suppressed <<
"\n";
143 if (net_size <= 32) {
146 }
else if (net_size <= 64) {
149 }
else if (net_size <= 128) {
152 }
else if (net_size <= 256) {
155 }
else if (net_size <= 512) {
158 }
else if (net_size <= 1024) {
161 }
else if (net_size <= 2 * 1024) {
164 }
else if (net_size <= 4 * 1024) {
167 }
else if (net_size <= 8 * 1024) {
170 }
else if (net_size <= 16 * 1024) {
173 }
else if (net_size <= 32 * 1024) {
176 }
else if (net_size <= 64 * 1024) {
211 size_t new_gross_size;
212 void *newbuf =
memAllocBuf(net_size, &new_gross_size);
215 size_t data_size = *gross_size;
217 if (data_size > net_size)
218 data_size = net_size;
220 memcpy(newbuf, oldbuf, data_size);
225 *gross_size = new_gross_size;
256 int64_t new_pool_limit;
265 debugs(13,
DBG_IMPORTANT,
"memory_pools_limit 0 has been changed to memory_pools_limit none. Please update your config");
275 auto tmp =
static_cast<int>(aMem);
276 aMem =
static_cast<mem_type>(++tmp);
284 static bool MemIsInitialized =
false;
285 if (MemIsInitialized)
321 MemIsInitialized =
true;
339 poolsInUse <<
" pools are left dirty");
483 const char *delim =
"\t ";
485 stream.setf(std::ios_base::fixed);
486 stream << std::setw(20) << std::left << mp_st->
label << delim;
487 stream << std::setw(4) << std::right << mp_st->
obj_size << delim;
503 stream << std::setw(4) << mp_st->
chunks_free << delim;
505 stream << std::setprecision(3) <<
xpercent(excess, needed) << delim;
554 stream <<
"Current memory usage:\n";
556 stream <<
"Pool\t Obj Size\t"
557 "Chunks\t\t\t\t\t\t\t"
558 "Allocated\t\t\t\t\t"
561 "Allocations Saved\t\t\t"
566 "(#)\t used\t free\t part\t %Frag\t "
567 "(#)\t (KB)\t high (KB)\t high (hrs)\t %Tot\t"
568 "(#)\t (KB)\t high (KB)\t high (hrs)\t %alloc\t"
569 "(#)\t (KB)\t high (KB)\t"
570 "(#)\t %cnt\t %vol\t"
580 std::vector<PoolStats> usedPools;
581 usedPools.reserve(poolsInUse);
586 pool->getStats(mp_stats);
589 usedPools.emplace_back(mp_stats);
595 std::sort(usedPools.begin(), usedPools.end(), [](
const PoolStats &a,
const PoolStats &b) {
596 return (double(a.obj_size) * a.meter->alloc.currentLevel()) > (double(b.obj_size) * b.meter->alloc.currentLevel());
599 for (
const auto &pool: usedPools) {
608 stream <<
"Current overhead: " << mp_total.
overhead <<
" bytes (" <<
615 stream <<
"Total Pools created: " << poolCount <<
"\n";
616 stream <<
"Pools ever used: " << poolCount - not_used <<
" (shown above)\n";
617 stream <<
"Currently in use: " << poolsInUse <<
"\n";
#define memPoolCreate
Creates a named MemPool of elements with the given size.
void setIdleLimit(const ssize_t newLimit)
std::list< Mem::Allocator * > pools
static MemPools & GetInstance()
void clean(time_t maxage)
int getInUseCount() const
the difference between the number of alloc() and freeOne() calls
virtual void setChunkSize(size_t)
XXX: Misplaced – not all allocators have a notion of a "chunk". See MemPoolChunked.
void freeOne(void *obj)
return memory reserved by alloc()
void zeroBlocks(const bool doIt)
void * alloc()
provide (and reserve) memory suitable for storing one object
PoolMeter meter
statistics tracked for this allocator
ssize_t currentLevel() const
struct SquidConfig::@90 onoff
struct SquidConfig::@95 MemPools
#define debugs(SECTION, LEVEL, CONTENT)
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
#define SQUID_MD5_DIGEST_LENGTH
mem_type
Types of memory pool which do not yet use MEMPROXY_CLASS() API.
size_t GlobalStats(PoolStats &)
void PoolReport(const PoolStats *, const PoolMeter *, std::ostream &)
void Report(std::ostream &)
void CleanIdlePools(void *unused)
void RegisterAction(char const *action, char const *desc, OBJH *handler, Protected, Atomic, Format)
void memFree(void *p, int type)
Free a element allocated by memAllocate()
static Mem::Meter HugeBufCountMeter
static void memFree512B(void *)
static Mem::Allocator *& GetPool(size_t type)
static void memFree4K(void *)
void memClean(void)
Main cleanup handler.
void memFreeBuf(size_t size, void *buf)
int memInUse(mem_type type)
static mem_type memFindBufSizeType(size_t net_size, size_t *gross_size)
void * memReallocBuf(void *oldbuf, size_t net_size, size_t *gross_size)
static void memFree128B(void *)
static mem_type & operator++(mem_type &aMem)
static void memFree1K(void *)
static void memFree64B(void *)
static void memFree2K(void *)
static void memFree16K(void *)
void * memAllocBuf(size_t net_size, size_t *gross_size)
static void memFree32K(void *)
static double clean_interval
void * memAllocate(mem_type type)
Allocate one element from the typed pool.
static void cxx_xfree(void *ptr)
static void memDataInit(mem_type type, const char *name, size_t size, int, bool doZero)
static void memFree32B(void *)
static Mem::Meter HugeBufVolumeMeter
static void memFree64K(void *)
static void memFree8K(void *)
static void memFree256B(void *)
FREE * memFreeBufFunc(size_t size)
double current_dtime
the current UNIX time in seconds (with microsecond precision)
double xpercent(double part, double whole)
double xdiv(double nom, double denom)
const char * double_to_str(char *buf, int buf_size, double value)