Typical usage could be:
+
+
-
+
+
+
Main cleanup handler. For MemPools to stay within upper idle limits,
this function needs to be called periodically, preferrably at some
constant rate, eg. from Squid event. It looks through all pools and
chunks, cleans up internal states and checks for releasable chunks.
+
Between the calls to this function objects are placed onto internal
cache instead of returning to their home chunks, mainly for speedup
purpoase. During that time state of chunk is not known, it is not
known whether chunk is free or in use. This call returns all objects
to their chunks and restores consistency.
+
Should be called relatively often, as it sorts chunks in suitable
order as to reduce free memory fragmentation and increase chunk
utilisation.
+
Parameter maxage instructs to release all totally idle chunks that
have not been referenced for maxage seconds.
+
Suitable frequency for cleanup is in range of few tens of seconds to
few minutes, depending of memory activity.
Several functions above call memPoolClean internally to operate on
...
myStructType *myStruct;
MemPool * myType_pool = memPoolCreate("This is cute pool", sizeof(myStructType));
@@ -3058,6 +3059,7 @@
...
memPoolFree(myStruct, myType_pool);
memPoolDestroy(&myType_pool)
+
MemPoolIterator *iter;
for (iter = memPoolIterate(); (pool = memPoolIterateNext(iter)); ) {
... handle(pool);
}
memPoolIterateDone(&iter);
+
struct _MemPoolStats {
MemPool *pool;
const char *label;
@@ -3172,6 +3176,7 @@
mgb_t gb_osaved; /* history Allocations */
mgb_t gb_freed; /* account Free calls */
};
+
struct _MemPoolGlobalStats {
MemPoolMeter *TheMeter;
@@ -3204,7 +3210,7 @@
int tot_overhead;
int mem_idle_limit;
};
-
+