<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLHeap/maxAvailableSize(alignment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLHeap(im)maxAvailableSizeWithAlignment:"
  },
  "title" : "maxAvailableSize(alignment:)"
}
-->

# maxAvailableSize(alignment:)

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

```
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

The maximum size for the resource, in bytes.

## Discussion

This method measures fragmentation within the heap. You can use the [`heapBufferSizeAndAlign(length:options:)`](/documentation/Metal/MTLDevice/heapBufferSizeAndAlign(length:options:)) and [`heapTextureSizeAndAlign(descriptor:)`](/documentation/Metal/MTLDevice/heapTextureSizeAndAlign(descriptor:)) methods to help you determine the correct alignment for the resource.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)