For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
  • Introduction
    • Overview
    • Relevant Technologies
    • Getting Started
  • Setup
    • SDK Installation
    • Additional Setup
    • Third Party Hardware Setup
  • Using the SDK
    • Holoscan Core
    • GPU Resident Execution
    • Holoscan by Example
    • Create an Application
    • Create a Distributed Application
    • Create an Operator
    • Create an Operator via Decorator
    • Create a Condition
    • Dynamic Flow Control
    • CUDA Stream Handling
    • Logging
    • Data Logging
    • Debugging
    • Python Operator Bindings
  • Operators
    • Operators and Extensions
    • Visualization
    • Inference
    • Testing
    • Video I/O Vendor Implementation Guide
  • Components
    • Schedulers
    • Conditions
    • Resources
    • Analytics
  • AI Skills
    • Ai Skills
  • API reference
          • Allocator
          • AnnotatedDoubleBufferReceiver
          • AnnotatedDoubleBufferTransmitter
          • AppDriver
          • Application
          • AppWorker
          • Arg
          • ArgList
          • ArgType
          • ArgumentSetter
          • AsyncBufferReceiver
          • AsyncBufferTransmitter
          • AsyncDataLoggerBackend
          • AsyncDataLoggerResource
          • AsynchronousCondition
          • BlockMemoryPool
          • BooleanCondition
          • CLIParser
          • Clock
          • ClockInterface
          • CodecRegistry
          • Component
          • ComponentBase
          • ComponentSpec
          • Condition
          • ConditionCombiner
          • Config
          • CountCondition
          • CPUResourceMonitor
          • CPUThread
          • CsvDataExporter
          • CudaAllocator
          • CudaBufferAvailableCondition
          • CudaContextScopedPush
          • CudaEventCondition
          • CudaFunctionLauncher
          • CudaGreenContext
          • CudaGreenContextPool
          • CudaObjectHandler
          • CudaStreamCondition
          • CudaStreamHandler
          • CudaStreamPool
          • DataExporter
          • DataFlowTracker
          • DataLogger
          • DataLoggerQueue
          • DataLoggerResource
          • DefaultFragmentService
          • DFFTCollector
          • DistributedAppService
          • DLManagedMemoryBufferVersioned
          • DoubleBufferReceiver
          • DoubleBufferTransmitter
          • DownstreamMessageAffordableCondition
          • Endpoint
          • EventBasedScheduler
          • ExecutionContext
          • Executor
          • ExpiringMessageAvailableCondition
          • ExtensionManager
          • FastDdsDiscovery
          • FastDdsEndpoint
          • FastDdsHoloscanEntityTypeSupport
          • FastDdsNativeBufferAdapter
          • FastDdsPubSubContext
          • FastDdsPubSubNetworkContext
          • FastDdsSerializer
          • FastDdsTransport
          • FileFIFOMutex
          • FirstFitAllocator
          • FirstFitAllocatorBase
          • FirstPixelOutCondition
          • FlowGraph
          • FlowGraphImpl
          • Fragment
          • FragmentAllocationStrategy
          • FragmentScheduler
          • FragmentService
          • FragmentServiceProvider
          • GPUDevice
          • GPUResidentDeck
          • GPUResidentExecutor
          • GPUResidentOperator
          • GPUResourceMonitor
          • GreedyFragmentAllocationStrategy
          • GreedyScheduler
          • GXFComponentResource
          • HoloEntitySerializerBase
          • HoloIpcCudaNativeBufferAdapterBase
          • HoloscanAsyncBufferReceiver
          • HoloscanAsyncBufferTransmitter
          • HoloscanLogger
          • HoloscanUcxReceiver
          • HoloscanUcxTransmitter
          • InMemoryPubSubNetworkContext
          • InMemoryPubSubSession
          • InputContext
          • IOSpec
          • LockFreeQueue
          • Logger
          • ManualClock
          • Map
          • MatXAllocator
          • MemoryAvailableCondition
          • Message
          • MessageAvailableCondition
          • MessageLabel
          • MetadataDictionary
          • MetaParameter
          • MultiMessageAvailableCondition
          • MultiMessageAvailableTimeoutCondition
          • MultiThreadScheduler
          • NativeBufferProtocolAdapter
          • NetworkContext
          • Nullable
          • Operator
          • OperatorSpec
          • OrConditionCombiner
          • OrderedQueue
          • OutputContext
          • ParameterWrapper
          • PathMetrics
          • PeriodicCondition
          • PoseTree
          • PoseTreeEdgeHistory
          • PoseTreeManager
          • PoseTreeUCXClient
          • PoseTreeUCXServer
          • PresentDoneCondition
          • PublisherAvailableCondition
          • PubSubContext
          • PubSubReceiver
          • PubSubTransmitter
          • RealtimeClock
          • Receiver
          • Resource
          • RMMAllocator
          • RuntimeError
          • Scheduler
          • ScopedFlock
          • ScopedWaitedFlock
          • SerializationBuffer
          • SessionDiscoveryFrontend
          • SessionTransportFrontend
          • SidecarDispatchQueue
          • SignalHandler
          • SO2
          • SO3
          • StdComponentSerializer
          • StdEntitySerializer
          • StdPubSubEntitySerializer
          • StreamOrderedAllocator
          • Subgraph
          • SubscriberAvailableCondition
          • SyntheticClock
          • SystemResourceManager
          • Tensor
          • TensorMap
          • ThreadPool
          • Timer
          • Topology
          • Transmitter
          • UcxComponentSerializer
          • UcxContext
          • UcxEntitySerializer
          • UcxHoloscanComponentSerializer
          • UcxReceiver
          • UcxSerializationBuffer
          • UcxTransmitter
          • UnboundedAllocator
  • Performance
    • Performance Considerations
    • Flow Tracking
    • GXF Job Statistics
    • Nsight Profiling
  • HoloHub
    • HoloHub Overview
  • FAQ
    • FAQ
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogoDocumentation
On this page
  • Constructors
  • FirstFitAllocatorBase
  • Methods
  • allocate
  • acquire
  • release
  • propagate_to_root
  • update
  • Types
  • Typedefs
  • Error
  • Member variables
  • Inner classes
  • Memory
API referenceC++ APIHoloscanClasses

holoscan::FirstFitAllocatorBase

Beta
||View as Markdown|
Previous

holoscan::FirstFitAllocator

Next

holoscan::FirstPixelOutCondition

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.

#include <holoscan/first_fit_allocator_base.hpp>

Constructors

FirstFitAllocatorBase

holoscan::FirstFitAllocatorBase::FirstFitAllocatorBase()holoscan::FirstFitAllocatorBase::FirstFitAllocatorBase()

Default constructor.


Methods

allocate

expected_t<void> holoscan::FirstFitAllocatorBase::allocate(
int32_t size
)

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

size
int32_t

Maximum size of memory that can be managed.

acquire

expected_t<int32_t> holoscan::FirstFitAllocatorBase::acquire(
int32_t size
)

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
int32_t

Size of the memory block to acquire.

release

expected_t<void> holoscan::FirstFitAllocatorBase::release(
int32_t index
)

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

index
int32_t

Starting index of the block to release.

propagate_to_root

void holoscan::FirstFitAllocatorBase::propagate_to_root(
int32_t idx
)

Update the tree path from a given node to the root.

Parameters

idx
int32_t

Index of the node to start propagation from.

update

void holoscan::FirstFitAllocatorBase::update(
int32_t left,
int32_t right,
int32_t free
)

Update a segment of the tree and mark it as free or allocated.

Parameters

left
int32_t

Left boundary of the segment (inclusive).

right
int32_t

Right boundary of the segment (exclusive).

free
int32_t

1 If marking as free, 0 if marking as allocated.


Types

Typedefs

NameDefinitionDescription
expected_texpected< T, Error >Expected type used by this class.
unexpected_tunexpected< Error >Unexpected type used by this class.

Error

Error codes used by the first-fit allocator classes.

NameValueDescription
kAlreadyInUseReturned when the suballocator is already in use and some memory has not been released yet.
kInvalidSizeReturned if the size is invalid (negative or too big).
kOutOfMemoryReturned if the class can’t allocate enough memory.
kBlockNotAllocatedReturned if we attempt to release a block of memory not allocated yet.
kLogicErrorThis error happens when there is a logical issue during execution. This should never happen.

Member variables

NameTypeDescription
tree_std::unique_ptr< Memory[]>Binary segment tree for memory management.
size_int32_tTotal size available at initialization.
last_layer_first_index_int32_tHelper index pointing to the first leaf node in the tree.

Inner classes

Memory

struct holoscan::FirstFitAllocatorBase::Memory

Helper data structure for efficient memory block searching.

Represents a node in a binary segment tree used to track free and allocated memory regions.

NameTypeDescription
leftint32_tSize of available memory starting from the left side of the subtree.
rightint32_tSize of available memory starting from the right side of the subtree.
maxint32_tSize of the largest available block in the subtree.
sizeint32_tConstant size of the subtree. When a block is acquired, contains the size that was acquired.