Class SizeLimiter

Inheritance Relationships

Base Type

Class Documentation

class SizeLimiter : public umpire::strategy::AllocationStrategy

An allocator with a limited total size.

Using this AllocationStrategy with another can be a good way to limit the total size of allocations made on a particular resource or from a particular context.

Public Functions

SizeLimiter(const std::string &name, int id, Allocator allocator, std::size_t size_limit)
void *allocate(std::size_t bytes)

Allocate bytes of memory.


Pointer to start of allocated bytes.

  • bytes: Number of bytes to allocate.

void deallocate(void *ptr)

Free the memory at ptr.

  • ptr: Pointer to free.

std::size_t 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.


Current total size of allocations.

std::size_t getHighWatermark() const

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()

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.

void release()

Release any and all unused memory held by this AllocationStrategy.

std::size_t 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.


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

const std::string &getName()

Get the name of this AllocationStrategy.


The name of this AllocationStrategy.

int getId()

Get the id of this AllocationStrategy.


The id of this AllocationStrategy.

Protected Attributes

std::string m_name
int m_id