> This page is for version 4.3.
> For other versions, use one of these documentation indexes:
> - 4.6 (Latest) (default): https://docs.nvidia.com/holoscan/sdk-user-guide/4-6-latest/llms.txt
> - ltsb-2.0: https://docs.nvidia.com/holoscan/sdk-user-guide/ltsb-2-0/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::utils::cuda::CudaHostMappedBuffer

> CUDA Host Mapped Buffer Class.

CUDA Host Mapped [Buffer](buffer) Class.

```cpp showLineNumbers={false}
#include <holoscan/utils/cuda/buffer.hpp>
```

**Inherits from:** `holoscan::utils::cuda::Buffer` (public)

---

## Constructors

### CudaHostMappedBuffer \[#cudahostmappedbuffer]

```cpp showLineNumbers={false}
holoscan::utils::cuda::CudaHostMappedBuffer::CudaHostMappedBuffer(
    size_t size,
    int device_id = 0
)
```

Construct a new Cuda Host Mapped [Buffer](buffer) object.

### Destructor \[#destructor]

### \~CudaHostMappedBuffer

```cpp showLineNumbers={false}
holoscan::utils::cuda::CudaHostMappedBuffer::~CudaHostMappedBuffer()
```

---

## Methods

### data \[#data]

```cpp showLineNumbers={false}
void * holoscan::utils::cuda::CudaHostMappedBuffer::data() override
```

Get the data buffer.

**Returns:** Void pointer to the buffer

### size \[#size]

```cpp showLineNumbers={false}
size_t holoscan::utils::cuda::CudaHostMappedBuffer::size() const override
```

Get the size of the allocated buffer in elements.

**Returns:** size in elements

### get\_bytes \[#getbytes]

```cpp showLineNumbers={false}
size_t holoscan::utils::cuda::CudaHostMappedBuffer::get_bytes() const override
```

Get the bytes allocated.

**Returns:** allocated bytes

### resize \[#resize]

```cpp showLineNumbers={false}
void holoscan::utils::cuda::CudaHostMappedBuffer::resize(
    size_t number_of_elements
) override
```

Resize the underlying buffer.

**Parameters**

**`number_of_elements`** `size_t`

Number of elements to be resized with

---

### device\_data \[#devicedata]

```cpp showLineNumbers={false}
void * holoscan::utils::cuda::CudaHostMappedBuffer::device_data() const
```

### get\_datatype \[#getdatatype]

```cpp showLineNumbers={false}
BufferDataType holoscan::utils::cuda::CudaHostMappedBuffer::get_datatype() const
```

Get the datatype.

**Returns:** datatype

### get\_device \[#getdevice]

```cpp showLineNumbers={false}
int holoscan::utils::cuda::CudaHostMappedBuffer::get_device() const
```

Get the device ID.

**Returns:** device ID

---

## Member variables

| Name             | Type                      | Description                             |
| ---------------- | ------------------------- | --------------------------------------- |
| `size_`          | `size_t`                  |                                         |
| `capacity_`      | `size_t`                  |                                         |
| `buffer_`        | `void *`                  |                                         |
| `device_buffer_` | `void *`                  |                                         |
| `allocator_`     | `CudaHostMappedAllocator` |                                         |
| `free_`          | `CudaHostFree`            |                                         |
| `data_type_`     | `BufferDataType`          | Datatype of the elements in the buffer. |
| `device_id_`     | `int`                     | Device ID.                              |