Class DynamicPoolMap

Inheritance Relationships

Base Type

Class Documentation

class umpire::strategy::DynamicPoolMap : public umpire::strategy::AllocationStrategy

Simple dynamic pool for allocations.

This AllocationStrategy uses Simpool to provide pooling for allocations of any size. The behavior of the pool can be controlled by two parameters: the initial allocation size, and the minimum allocation size.

The initial size controls how large the first piece of memory allocated is, and the minimum size controls the lower bound on all future chunk allocations.

Public Types

using Pointer = void*
using CoalesceHeuristic = std::function<bool(const strategy::DynamicPoolMap&)>

Callback heuristic to trigger coalesce of free blocks in pool.

The registered heuristic callback function will be called immediately after a deallocation() has completed from the pool.

Public Functions

DynamicPoolMap(const std::string &name, int id, Allocator allocator, const std::size_t initial_alloc_size = (512 * 1024 * 1024), const std::size_t min_alloc_size = (1 * 1024 * 1024), const std::size_t align_bytes = 16, CoalesceHeuristic coalesce_heuristic = heuristic_percent_releasable(100)) noexcept

Construct a new DynamicPoolMap.

  • name: Name of this instance of the DynamicPoolMap

  • id: Unique identifier for this instance

  • initial_alloc_bytes: Size the pool initially allocates

  • min_alloc_bytes: The minimum size of all future allocations

  • coalesce_heuristic: Heuristic callback function

  • align_bytes: Number of bytes with which to align allocation sizes


Destructs the DynamicPoolMap.

DynamicPoolMap(const DynamicPoolMap&) = delete
void *allocate(std::size_t bytes) override

Allocate bytes of memory.


Pointer to start of allocated bytes.

  • bytes: Number of bytes to allocate.

void deallocate(void *ptr) override

Free the memory at ptr.

  • ptr: Pointer to free.

void release() override

Release any and all unused memory held by this AllocationStrategy.

std::size_t getCurrentSize() const noexcept override

Get current (total) size of the allocated memory.

This is the total size of all allocation currently ‘live’ that have been made by this AllocationStrategy object.


Current total size of allocations.

std::size_t getActualSize() const noexcept override

Get the current amount of memory allocated by this allocator.

Note that this can be larger than getCurrentSize(), particularly if the AllocationStrategy implements some kind of pooling.


The total size of all the memory this object has allocated.

std::size_t getHighWatermark() const noexcept override

Get the high watermark of the total allocated size.

This is equivalent to the highest observed value of getCurrentSize.


High watermark allocation size.

Platform getPlatform() noexcept override

Get the platform associated with this AllocationStrategy.

The Platform distinguishes the appropriate place to execute operations on memory allocated by this AllocationStrategy.


The platform associated with this AllocationStrategy.

MemoryResourceTraits getTraits() const noexcept override
std::size_t getReleasableSize() const noexcept

Returns the number of bytes of unallocated data held by this pool that could be immediately released back to the resource.

A memory pool has a set of blocks that are not leased out to the application as allocations. Allocations from the resource begin as a single chunk, but these could be split, and only the first chunk can be deallocated back to the resource immediately.


The total number of bytes that are immediately releasable.

std::size_t getFreeBlocks() const noexcept

Return the number of free memory blocks that the pools holds.

std::size_t getInUseBlocks() const noexcept

Return the number of used memory blocks that the pools holds.

std::size_t getBlocksInPool() const noexcept

Return the number of memory blocks both leased to application and internal free memory that the pool holds.

std::size_t getLargestAvailableBlock() noexcept

Get the largest allocatable number of bytes from pool before the pool will grow.

return The largest number of bytes that may be allocated without causing pool growth

void coalesce()

Merge as many free records as possible, release all possible free blocks, then reallocate a chunk to keep the actual size the same.

std::size_t getAllocationCount() const noexcept

Get the total number of active allocations by this allocator.


The total number of active allocations this object has allocated.

const std::string &getName() noexcept

Get the name of this AllocationStrategy.


The name of this AllocationStrategy.

int getId() noexcept

Get the id of this AllocationStrategy.


The id of this AllocationStrategy.

Protected Attributes

std::string m_name
int m_id