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 SQUID_SRC_MEM_POOL_H
10 #define SQUID_SRC_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)) )
53 #define toKB(size) ( (size + 1024 - 1) / 1024 )
55 
58 
60 class MemPools
61 {
62 public:
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 
115 private:
119  ssize_t idleLimit_ = (2 << 20);
120 };
121 
123 #define memPoolCreate MemPools::GetInstance().create
124 
125 #endif /* SQUID_SRC_MEM_POOL_H */
126 
void clean(time_t maxage)
Definition: Pool.cc:105
std::list< Mem::Allocator * > pools
Definition: Pool.h:112
void setIdleLimit(const ssize_t newLimit)
Definition: Pool.h:78
ssize_t idleLimit() const
Definition: Pool.h:80
MemPools()
Definition: Pool.cc:40
bool defaultIsChunked
Definition: Pool.h:113
void setDefaultPoolChunking(bool const &)
Definition: Pool.cc:63
static MemPools & GetInstance()
Definition: Pool.cc:27
Mem::PoolMeter TheMeter
memory usage totals as of latest MemPools::flushMeters() event
Definition: Pool.cc:24
Definition: Pool.h:60
void flushMeters()
Definition: Pool.cc:72
ssize_t idleLimit_
Definition: Pool.h:119
Mem::Allocator * create(const char *, size_t)
Definition: Pool.cc:47

 

Introduction

Documentation

Support

Miscellaneous