---
title: "maxAvailableSize(alignment:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlheap/maxavailablesize(alignment:)"
---

# maxAvailableSize(alignment:)

The maximum size of a resource, in bytes, that can be currently allocated from the heap.

## Declaration

```swift
func maxAvailableSize(alignment: Int) -> Int
```

## Parameters

- `alignment`: The alignment of the resource, in bytes. This value needs to be a power of two.

## Return Value

Return Value The maximum size for the resource, in bytes.

## Discussion

Discussion This method measures fragmentation within the heap. You can use the heapBufferSizeAndAlign(length:options:) and heapTextureSizeAndAlign(descriptor:) methods to help you determine the correct alignment for the resource.

## See Also

### Checking a heap’s size information

- [size](metal/mtlheap/size.md)
- [usedSize](metal/mtlheap/usedsize.md)
- [currentAllocatedSize](metal/mtlheap/currentallocatedsize.md)
