holoscan::FirstFitAllocatorBase
holoscan::FirstFitAllocatorBase
holoscan::FirstFitAllocatorBase
Memory management helper class using first-fit allocation strategy.
This class keeps track of allocated and free regions within a large memory chunk and can efficiently find the first available block that fits a requested size. It works only with indices and relies on an external class to hold the actual memory.
Internally, it uses a binary segment tree to track the largest available block in any given area of memory. All operations have logarithmic time complexity.
Default constructor.
Allocate internal data structures to handle memory requests for a given size.
Requires 32 * 2^ceil(log2(size)) bytes of memory for internal bookkeeping.
Returns: Success or error status. Error::kInvalidSize if size is invalid.
Parameters
Maximum size of memory that can be managed.
Acquire a contiguous block of memory of the specified size.
If such a contiguous block exists, returns the lowest index where the block starts. This block will be marked as allocated until a call to release() is made.
Returns: Index of the allocated block on success, Error::kOutOfMemory if no suitable block exists.
Parameters
Size of the memory block to acquire.
Release a previously acquired block of memory.
The block must have been previously acquired using acquire(). Once released, the memory becomes available for future allocations.
Returns: Success or error status. Error::kBlockNotAllocated if the block was not previously allocated.
Parameters
Starting index of the block to release.
Update the tree path from a given node to the root.
Parameters
Index of the node to start propagation from.
Update a segment of the tree and mark it as free or allocated.
Parameters
Left boundary of the segment (inclusive).
Right boundary of the segment (exclusive).
1 If marking as free, 0 if marking as allocated.
Error codes used by the first-fit allocator classes.
Helper data structure for efficient memory block searching.
Represents a node in a binary segment tree used to track free and allocated memory regions.