---
title: "makeBuffer(length:options:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlheap/makebuffer(length:options:)"
---

# makeBuffer(length:options:)

Creates a buffer on the heap.

## Declaration

```swift
func makeBuffer(length: Int, options: MTLResourceOptions = []) -> (any MTLBuffer)?
```

## Parameters

- `length`: The size, in bytes, of the buffer.
- `options`: Options that describe the properties of the buffer.

## Return Value

Return Value A new buffer object backed by heap memory, or nil if the heap memory is full.

## Discussion

Discussion You can call the method with the following restrictions: The heap’s type needs to be MTLHeapType.automatic The buffer’s storage mode option needs to match the heap’s storageMode property The buffer’s CPU cache mode option needs to match the heap’s cpuCacheMode property

## See Also

### Creating buffers from a heap

- [makeBuffer(length:options:offset:)](metal/mtlheap/makebuffer(length:options:offset:).md)
