cmempool · Section 3
crmempool_allocated_bytes
NAME
crmempool_allocated_bytes - report the memory a ranged pool holds for its entries
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cmempool.h> size_t crmempool_allocated_bytes(crmempool *rmp);
DESCRIPTION
Returns the sizes of the entry blocks of all the tiers added together, in bytes, which is what a ranged pool really costs. Each tier is a pool of its own with its own element size and element count, and every tier that is large enough to keep a cache for each thread holds its own reserve, so this total is larger than the sum of the tier capacities. Use this figure to fit a ranged pool into a memory budget, which is the case where working it out by hand is hardest.
PARAMETERS
rmp Ranged memory pool to query (must not be NULL)
RETURN VALUE
Returns the size in bytes of the entry block of every tier, added together
NOTES
Only the entry blocks of the tiers are counted, on the same terms as cmempool_allocated_bytes(3). The handles, each thread's cache and every entry that a fallback policy serves are all left out. The value stays the same for the whole lifetime of the pool. The function asserts if rmp is NULL.
THREAD SAFETY
Thread-safe when the pool was created with single_threaded = false. The call takes the lock of each tier in turn, so it belongs on a cold path; don't use it inside a hot loop.
SEE ALSO
cmempool_allocated_bytes(3), crmempool_total_capacity(3), crmempool_create_mp(3)