Follow-on to PR #25325, “Add pool based memory resource”
The DynamicUsage()
function for the version of unordered_map
that uses the PoolAllocator
returns a close approximation of the amount of physical memory used by the map. (This is the map used for the dbcache.) It accounts for several of the allocator’s internal data structures, such as the memory chunks and the freelist. It also includes the unordered_map
’s bucket array (vector), which is a bit out of place because the rest of the pool allocator doesn’t know or make any assumption about the type of container that the pool allocator is being used for, namely, currently only std::unordered_map
.
This change could prevent a possible future pool memory usage calculation error, although it would likely be a small error: If the pool is configured with a large MAX_BLOCK_SIZE_BYTES
, it could turn out that the size of the bucket array is small enough to be allocated by the resource allocator; it would then be double-counted.
Another aspect of the pool allocator that this PR improves is a refactor of the pool allocator’s DynamicUsage()
implementation, to move details about the pool allocator’s internal data structures out of memusage.h
, which is a general source file, to the allocator’s pool.h
.