MCPcopy Create free account
hub / github.com/acl-dev/acl / memShrink

Function memShrink

lib_acl/src/stdlib/memory/squid_allocator.c:102–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102static void memShrink(SQUID_MEM_ALLOCATOR *allocator, size_t new_limit)
103{
104 size_t start_limit = allocator->TheMeter.idle.level;
105 ACL_ITER iter;
106
107 /* first phase: cut proportionally to the pool idle size */
108
109 acl_foreach_reverse(iter, ((ACL_ALLOCATOR *) allocator)->pools) {
110 MemPool *pool = (MemPool*) iter.data;
111 const size_t target_pool_size = (size_t) ((double)
112 pool->meter.idle.level * new_limit) / start_limit;
113 memPoolShrink(allocator, pool, target_pool_size);
114 }
115
116 acl_msg_info("memShrink: 1st phase done with %ld KB left",
117 (long int) toKB(allocator->TheMeter.idle.level));
118
119 /* second phase: cut to 0 */
120
121 acl_foreach_reverse(iter, ((ACL_ALLOCATOR *) allocator)->pools) {
122 MemPool *pool = (MemPool*) iter.data;
123 memPoolShrink(allocator, pool, 0);
124 }
125
126 acl_msg_info("memShrink: 2nd phase done with %ld KB left",
127 (long int) toKB(allocator->TheMeter.idle.level));
128 acl_assert(allocator->TheMeter.idle.level <= new_limit); /* paranoid */
129}
130
131static void memCleanModule(ACL_ALLOCATOR *allocator)
132{

Callers 1

memConfigureFunction · 0.85

Calls 3

memPoolShrinkFunction · 0.85
acl_msg_infoFunction · 0.85
toKBFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…