---
title: MTLHeap
framework: metal
role: symbol
role_heading: Protocol
path: metal/mtlheap
---

# MTLHeap

A memory pool from which you can suballocate resources.

## Declaration

```swift
protocol MTLHeap : MTLAllocation
```

## Mentioned in

Simplifying GPU resource management with residency sets Creating sparse heaps and sparse textures Improving CPU performance by using argument buffers Reducing the memory footprint of Metal apps

## Overview

Overview Don’t implement this protocol yourself; instead, to create a heap, configure an MTLHeapDescriptor instance and call the makeHeap(descriptor:) method of an MTLDevice instance. You suballocate resources from a heap and make them aliasable or non-aliasable. A sub-allocated resource is non-aliased by default, preventing future resources allocated from the heap from using its memory. Resources are aliased when they share the same memory allocation on a heap. All resources sub-allocated from the same heap share the same storage mode and CPU cache mode. You can make heaps purgeable, but not the resources allocated from the heap; they can only reflect the heap’s purgeability state.

## Topics

### Naming and identifying a heap

- [label](metal/mtlheap/label.md)

### Creating buffers from a heap

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

### Creating textures from a heap

- [makeTexture(descriptor:)](metal/mtlheap/maketexture(descriptor:).md)
- [makeTexture(descriptor:offset:)](metal/mtlheap/maketexture(descriptor:offset:).md)

### Creating acceleration structure from a heap

- [makeAccelerationStructure(size:)](metal/mtlheap/makeaccelerationstructure(size:).md)
- [makeAccelerationStructure(size:offset:)](metal/mtlheap/makeaccelerationstructure(size:offset:).md)
- [makeAccelerationStructure(descriptor:)](metal/mtlheap/makeaccelerationstructure(descriptor:).md)
- [makeAccelerationStructure(descriptor:offset:)](metal/mtlheap/makeaccelerationstructure(descriptor:offset:).md)

### Configuring a heap’s purgeable state

- [setPurgeableState(_:)](metal/mtlheap/setpurgeablestate(_:).md)

### Checking a heap’s size information

- [maxAvailableSize(alignment:)](metal/mtlheap/maxavailablesize(alignment:).md)
- [size](metal/mtlheap/size.md)
- [usedSize](metal/mtlheap/usedsize.md)
- [currentAllocatedSize](metal/mtlheap/currentallocatedsize.md)

### Checking a heap’s permanent configuration

- [device](metal/mtlheap/device.md)
- [type](metal/mtlheap/type.md)
- [storageMode](metal/mtlheap/storagemode.md)
- [cpuCacheMode](metal/mtlheap/cpucachemode.md)
- [hazardTrackingMode](metal/mtlheap/hazardtrackingmode.md)
- [resourceOptions](metal/mtlheap/resourceoptions.md)

## Relationships

### Inherits From

- [MTLAllocation](metal/mtlallocation.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Resource memory allocation and management

- [Using argument buffers with resource heaps](metal/using-argument-buffers-with-resource-heaps.md)
- [Implementing a multistage image filter using heaps and events](metal/implementing-a-multistage-image-filter-using-heaps-and-events.md)
- [Implementing a multistage image filter using heaps and fences](metal/implementing-a-multistage-image-filter-using-heaps-and-fences.md)
- [MTLHeapDescriptor](metal/mtlheapdescriptor.md)
- [MTLHeapType](metal/mtlheaptype.md)
- [MTLSizeAndAlign](metal/mtlsizeandalign.md)
