---
title: "heapBufferSizeAndAlign(length:options:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtldevice/heapbuffersizeandalign(length:options:)"
---

# heapBufferSizeAndAlign(length:options:)

Returns the size and alignment, in bytes, of a buffer if you create it from a heap.

## Declaration

```swift
func heapBufferSizeAndAlign(length: Int, options: MTLResourceOptions = []) -> MTLSizeAndAlign
```

## Parameters

- `length`: The size of the buffer, in bytes.
- `options`: An doc://com.apple.metal/documentation/Metal/MTLResourceOptions instance for a would-be buffer’s storage and hazard tracking modes. See doc://com.apple.metal/documentation/Metal/resource-fundamentals and doc://com.apple.metal/documentation/Metal/setting-resource-storage-modes for more information.

## Return Value

Return Value An MTLSizeAndAlign instance.

## Discussion

Discussion Use this method to help estimate an appropriate size for a new heap before you create it.

## See Also

### Working with resource heaps

- [makeHeap(descriptor:)](metal/mtldevice/makeheap(descriptor:).md)
- [heapTextureSizeAndAlign(descriptor:)](metal/mtldevice/heaptexturesizeandalign(descriptor:).md)
- [heapAccelerationStructureSizeAndAlign(size:)](metal/mtldevice/heapaccelerationstructuresizeandalign(size:).md)
- [heapAccelerationStructureSizeAndAlign(descriptor:)](metal/mtldevice/heapaccelerationstructuresizeandalign(descriptor:).md)
- [MTLSizeAndAlign](metal/mtlsizeandalign.md)
