> This page is for version 5.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 5.0 (Latest) (default): https://docs.nvidia.com/holoscan/sdk-user-guide/5-0-latest/llms.txt
> - ltsb-2.0: https://docs.nvidia.com/holoscan/sdk-user-guide/ltsb-2-0/llms.txt
> - 4.6: https://docs.nvidia.com/holoscan/sdk-user-guide/4-6/llms.txt
> - 4.5: https://docs.nvidia.com/holoscan/sdk-user-guide/4-5/llms.txt
> - 4.4: https://docs.nvidia.com/holoscan/sdk-user-guide/4-4/llms.txt
> - 4.3: https://docs.nvidia.com/holoscan/sdk-user-guide/4-3/llms.txt
> - Archives: https://docs.nvidia.com/holoscan/sdk-user-guide/archives/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::CudaStreamAllocator

> CUDA-specific allocator extension for stream-ordered allocation and release.

CUDA-specific allocator extension for stream-ordered allocation and release.

Keeping this separate from [Allocator](allocator) lets CPU/system allocators avoid CUDA stream concepts while CUDA-backed [Tensor](tensor) storage can still pass CCCL stream references through the native Holoscan API.

```cpp showLineNumbers={false}
#include <holoscan/cuda_stream_allocator.hpp>
```

**Inherits from:** `holoscan::Allocator` (public)

---

## Constructors

### Destructor \[#destructor]

### \~CudaStreamAllocator

```cpp showLineNumbers={false}
holoscan::CudaStreamAllocator::~CudaStreamAllocator() override = default
```

---

## Methods

### allocate_async \[#allocateasync]

#### Overload 1

```cpp showLineNumbers={false}
expected<std::byte *, Error> holoscan::CudaStreamAllocator::allocate_async(
    uint64_t size,
    MemoryStorageType storage_type,
    cudaStream_t stream
)
```

#### Overload 2

```cpp showLineNumbers={false}
expected<std::byte *, Error> holoscan::CudaStreamAllocator::allocate_async(
    uint64_t size,
    MemoryStorageType storage_type,
    ::cuda::stream_ref stream
)
```

### free_async \[#freeasync]

#### Overload 1

```cpp showLineNumbers={false}
expected<void, Error> holoscan::CudaStreamAllocator::free_async(
    std::byte *pointer,
    cudaStream_t stream
)
```

#### Overload 2

```cpp showLineNumbers={false}
expected<void, Error> holoscan::CudaStreamAllocator::free_async(
    std::byte *pointer,
    ::cuda::stream_ref stream
)
```

### is_available \[#isavailable]

```cpp showLineNumbers={false}
virtual expected<void, Error> holoscan::CudaStreamAllocator::is_available(
    uint64_t size,
    MemoryStorageType storage_type
)
```

### allocate \[#allocate]

```cpp showLineNumbers={false}
virtual expected<std::byte *, Error> holoscan::CudaStreamAllocator::allocate(
    uint64_t size,
    MemoryStorageType storage_type
)
```

### free \[#free]

```cpp showLineNumbers={false}
virtual expected<void, Error> holoscan::CudaStreamAllocator::free(
    std::byte *pointer
)
```

### block_size \[#blocksize]

```cpp showLineNumbers={false}
virtual uint64_t holoscan::CudaStreamAllocator::block_size(
    MemoryStorageType storage_type
) const
```

### device_id \[#deviceid]

```cpp showLineNumbers={false}
virtual int32_t holoscan::CudaStreamAllocator::device_id(
    MemoryStorageType storage_type
) const
```

### allocate_async_impl \[#allocateasyncimpl]

```cpp showLineNumbers={false}
virtual expected<std::byte *, Error> holoscan::CudaStreamAllocator::allocate_async_impl(
    uint64_t size,
    MemoryStorageType storage_type,
    cudaStream_t stream
)
```

### free_async_impl \[#freeasyncimpl]

```cpp showLineNumbers={false}
virtual expected<void, Error> holoscan::CudaStreamAllocator::free_async_impl(
    std::byte *pointer,
    cudaStream_t stream
)
```

---

## Member variables

| Name                                | Type      | Description |
| ----------------------------------- | --------- | ----------- |
| `kUnknownDeviceId` static constexpr | `int32_t` |             |