Pool.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef _MEM_POOL_H_
10#define _MEM_POOL_H_
11
31#include "mem/forward.h"
32#include "mem/Meter.h"
33#include "util.h"
34
35#include <list>
36#if HAVE_GNUMALLOC_H
37#include <gnumalloc.h>
38#elif HAVE_MALLOC_H
39#include <malloc.h>
40#endif
41#if HAVE_MEMORY_H
42#include <memory.h>
43#endif
44
45#if !M_MMAP_MAX
46#if USE_DLMALLOC
47#define M_MMAP_MAX -4
48#endif
49#endif
50
52#define toMB(size) ( ((double) size) / ((double)(1024*1024)) )
54#define toKB(size) ( (size + 1024 - 1) / 1024 )
55
58
61{
62public:
63 static MemPools &GetInstance();
64 MemPools();
65 void flushMeters();
66
71 Mem::Allocator *create(const char *, size_t);
72
78 void setIdleLimit(const ssize_t newLimit) { idleLimit_ = newLimit; }
80 ssize_t idleLimit() const { return idleLimit_; }
81
108 void clean(time_t maxage);
109
110 void setDefaultPoolChunking(bool const &);
111
112 std::list<Mem::Allocator *> pools;
113 bool defaultIsChunked = false;
114
115private:
119 ssize_t idleLimit_ = (2 << 20);
120};
121
123#define memPoolCreate MemPools::GetInstance().create
124
125#endif /* _MEM_POOL_H_ */
126
Mem::PoolMeter TheMeter
memory usage totals as of latest MemPools::flushMeters() event
Definition: Pool.cc:24
Definition: Pool.h:61
void setIdleLimit(const ssize_t newLimit)
Definition: Pool.h:78
bool defaultIsChunked
Definition: Pool.h:113
void setDefaultPoolChunking(bool const &)
Definition: Pool.cc:63
MemPools()
Definition: Pool.cc:40
ssize_t idleLimit_
Definition: Pool.h:119
ssize_t idleLimit() const
Definition: Pool.h:80
std::list< Mem::Allocator * > pools
Definition: Pool.h:112
void flushMeters()
Definition: Pool.cc:72
Mem::Allocator * create(const char *, size_t)
Definition: Pool.cc:47
static MemPools & GetInstance()
Definition: Pool.cc:27
void clean(time_t maxage)
Definition: Pool.cc:105

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors