<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/managing-sparse-texture-memory",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Managing sparse texture memory"
}
-->

# Managing sparse texture memory

Take direct control of memory allocation for texture data by using sparse textures.

## Discussion

When you create a texture, by default, Metal allocates memory to hold the texture’s pixel data. In some cases, such as when you’re implementing texture streaming, you generally use only a fraction of this memory. When you use sparse textures, you take ownership of memory management for texture data and decide when to allocate and deallocate memory for a texture. In this way, sparse textures help you to use memory more efficiently.

To use sparse textures, allocate a sparse heap from which to allocate memory, and then create sparse textures from this heap. Initially, a texture has no storage. To add storage to a region inside the texture, ask the GPU to map memory from the heap for that region. A *sparse tile* is a memory allocation (as opposed to memory tiles a GPU uses for tile-based rendering). Sparse tiles are conceptually similar to virtual memory pages. When you don’t need a region to have storage, you can unmap its sparse tile and recover that memory.

![A figure showing a single sparse heap and two sparse textures. Each texture has a few regions mapped to sparse tiles on the heap.](images/com.apple.metal/managing-sparse-texture-memory-1@2x.png)

Because sparse textures work closely with texture mipmaps, you should be familiar with mipmaps before using sparse textures. For more information, see [Improving texture sampling quality and performance with mipmaps](/documentation/Metal/improving-texture-sampling-quality-and-performance-with-mipmaps).

### Check for sparse texture support

Not all GPUs support sparse textures. Check for support on the device object before attempting to use sparse textures:

```objective-c
- (Boolean) supportsSparseTextures
{
    return [_device supportsFamily: MTLGPUFamilyApple6 ];
}
```

---

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)