Class FixedPool¶
Defined in File FixedPool.hpp
Inheritance Relationships¶
Base Type¶
public umpire::strategy::AllocationStrategy
(Class AllocationStrategy)
Class Documentation¶
-
class
umpire::strategy
::
FixedPool
: public umpire::strategy::AllocationStrategy¶ Pool for fixed size allocations.
This AllocationStrategy provides an efficient pool for fixed size allocations, and used to quickly allocate and deallocate objects.
Public Functions
-
FixedPool
(const std::string &name, int id, Allocator allocator, const std::size_t object_bytes, const std::size_t objects_per_pool = 64 * sizeof(int) * 8) noexcept¶ Constructs a FixedPool.
- Parameters
name
: The allocator name for reference later in ResourceManagerid
: The allocator id for reference later in ResourceManagerallocator
: Used for data allocation. It uses std::malloc for internal tracking of these allocations.object_bytes
: The fixed size (in bytes) for each allocationobjects_per_pool
: Number of objects in each sub-pool internally. Performance likely improves if this is large, at the cost of memory usage. This does not have to be a multiple of sizeof(int)*8, but it will also likely improve performance if so.
-
~FixedPool
()¶
-
void *
allocate
(std::size_t bytes = 0) final override¶ Allocate bytes of memory.
- Return
Pointer to start of allocated bytes.
- Parameters
bytes
: Number of bytes to allocate.
-
void
deallocate
(void *ptr) final override¶ Free the memory at ptr.
- Parameters
ptr
: Pointer to free.
-
std::size_t
getCurrentSize
() const noexcept final 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.
- Return
Current total size of allocations.
-
std::size_t
getHighWatermark
() const noexcept final override¶ Get the high watermark of the total allocated size.
This is equivalent to the highest observed value of getCurrentSize.
- Return
High watermark allocation size.
-
std::size_t
getActualSize
() const noexcept final 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.
- Return
The total size of all the memory this object has allocated.
-
Platform
getPlatform
() noexcept final override¶ 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.
-
MemoryResourceTraits
getTraits
() const noexcept final override¶
-
bool
pointerIsFromPool
(void *ptr) const noexcept¶
-
std::size_t
numPools
() const noexcept¶
-
void
release
()¶ Release any and all unused memory held by this AllocationStrategy.
-
std::size_t
getAllocationCount
() const noexcept¶ Get the total number of active allocations by this allocator.
- Return
The total number of active allocations this object has allocated.
-
const std::string &
getName
() noexcept¶ Get the name of this AllocationStrategy.
- Return
The name of this AllocationStrategy.
-
int
getId
() noexcept¶ Get the id of this AllocationStrategy.
- Return
The id of this AllocationStrategy.
-
AllocationStrategy *
getParent
() const noexcept¶ Traces where the allocator came from.
- Return
Pointer to the parent AllocationStrategy.
-