Class DynamicPool¶
- Defined in File DynamicPool.hpp
Inheritance Relationships¶
Base Type¶
public umpire::strategy::AllocationStrategy
(Class AllocationStrategy)
Class Documentation¶
-
class
DynamicPool
: 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
Coalesce_Heuristic
= std::function<bool(const strategy::DynamicPool&)>¶ 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
-
DynamicPool
(const std::string &name, int id, Allocator allocator, const std::size_t min_initial_alloc_size = (512 * 1024 * 1024), const std::size_t min_alloc_size = (1 * 1024 * 1024), Coalesce_Heuristic coalesce_heuristic = heuristic_percent_releasable(100))¶ Construct a new DynamicPool.
- Parameters
name
: Name of this instance of the DynamicPool.id
: Id of this instance of the DynamicPool.min_initial_alloc_size
: The minimum size of the first allocation the pool will make.min_alloc_size
: The minimum size of all future allocations.coalesce_heuristic
: Heuristic callback function.
-
void *
allocate
(size_t bytes)¶ Allocate bytes of memory.
- Return
- Pointer to start of allocated bytes.
- Parameters
bytes
: Number of bytes to allocate.
-
void
deallocate
(void *ptr)¶ Free the memory at ptr.
- Parameters
ptr
: Pointer to free.
-
void
release
()¶ Release any and all unused memory held by this AllocationStrategy.
-
long
getCurrentSize
() const¶ 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.
- Return
- Current total size of allocations.
-
long
getActualSize
() const¶ 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.
- Return
- The total size of all the memory this object has allocated.
-
long
getHighWatermark
() const¶ Get the high watermark of the total allocated size.
This is equivalent to the highest observed value of getCurrentSize.
- Return
- High watermark allocation size.
-
Platform
getPlatform
()¶ Get the platform associated with this AllocationStrategy.
The Platform distinguishes the appropriate place to execute operations on memory allocated by this AllocationStrategy.
- Return
- The platform associated with this AllocationStrategy.
-
long
getReleasableSize
() const¶ Get the number of bytes that may be released back to resource.
A memory pool has a set of blocks that have no allocations against them. If the size of the set is greater than one, then the pool will have a number of bytes that may be released back to the resource or coalesced into a larger block.
- Return
- The total number of bytes that are releasable
-
long
getBlocksInPool
() const¶ Get the number of memory blocks that the pools has.
- Return
- The total number of blocks that are allocated by the pool
-
void
coalesce
()¶
-
const std::string &
getName
() Get the name of this AllocationStrategy.
- Return
- The name of this AllocationStrategy.
-
int
getId
() Get the id of this AllocationStrategy.
- Return
- The id of this AllocationStrategy.
Protected Attributes
-
std::string
m_name
-
int
m_id
-
using