# gpuopen-librariesandsdks/vulkanmemoryallocator architecture

> Architecture diagram of the GitHub repository gpuopen-librariesandsdks/vulkanmemoryallocator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gpuopen-librariesandsdks/vulkanmemoryallocator
- Repository: https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator

## Overview

Vulkan Memory Allocator (VMA) is a single-header C++ implementation with a Vulkan-style public API. Its central workflow is that an engine requests a buffer or image with allocation preferences; VMA selects memory, allocates a suitable block and region, then creates and binds the resource. The README also documents optional mapping, pools, sparse binding, defragmentation, statistics, diagnostics, and virtual allocation. These capabilities are documented in the header but its implementation was not sampled, so internal links reflect README evidence rather than inspected call sites.

Main entry points: [`include/vk_mem_alloc.h`](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h) (VMA API), [`tools/GpuMemDumpVis/GpuMemDumpVis.py`](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/tools/GpuMemDumpVis/GpuMemDumpVis.py) (Dump visualizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_allocation["Allocation and resources"]
  node_api["VMA API<br/>[vk_mem_alloc.h]"]
  node_memory_type["Memory selection<br/>[vk_mem_alloc.h]"]
  node_resource_create["Resource creation<br/>[vk_mem_alloc.h]"]
end

subgraph group_memory["Memory management"]
  node_block_alloc["Block allocation<br/>[vk_mem_alloc.h]"]
  node_pools["Custom pools<br/>[vk_mem_alloc.h]"]
  node_mapping["Mapping and cache<br/>[vk_mem_alloc.h]"]
  node_sparse["Sparse binding<br/>[vk_mem_alloc.h]"]
  node_virtual["Virtual allocation<br/>[vk_mem_alloc.h]"]
  node_defrag["Defragmentation<br/>[vk_mem_alloc.h]"]
end

subgraph group_insight["Diagnostics and visualization"]
  node_stats["Statistics and budget<br/>[vk_mem_alloc.h]"]
  node_dump["JSON memory dump<br/>[vk_mem_alloc.h]"]
  node_debug["Debug annotations<br/>[vk_mem_alloc.h]"]
  node_visualizer["Dump visualizer<br/>[GpuMemDumpVis.py]"]
end

subgraph group_integration["Vulkan integration"]
  node_vulkan["Vulkan runtime"]
end

node_engine(("Engine client"))

node_engine -->|"requests allocation"| node_api
node_api -->|"selects memory"| node_memory_type
node_api -->|"creates resource"| node_resource_create
node_api -->|"reserves region"| node_block_alloc
node_resource_create -->|"allocates memory"| node_block_alloc
node_resource_create -->|"creates and binds"| node_vulkan
node_api -->|"supports"| node_pools
node_api -->|"maps and flushes"| node_mapping
node_api -->|"allocates pages"| node_sparse
node_api -->|"allocates custom data"| node_virtual
node_api -->|"moves allocations"| node_defrag
node_api -->|"reports usage"| node_stats
node_api -->|"exports state"| node_dump
node_api -->|"annotates allocations"| node_debug
node_engine -->|"visualizes dump"| node_visualizer
node_dump -->|"provides JSON"| node_visualizer

click node_api "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_memory_type "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_resource_create "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_block_alloc "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_pools "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_mapping "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_sparse "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_virtual "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_defrag "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_stats "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_dump "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_debug "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h"
click node_visualizer "https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/tools/GpuMemDumpVis/GpuMemDumpVis.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_memory_type,node_resource_create,node_engine toneBlue
class node_block_alloc,node_pools,node_mapping,node_sparse,node_virtual,node_defrag toneAmber
class node_stats,node_dump,node_debug,node_visualizer toneMint
class node_vulkan toneRose
```

## Components

### Allocation and resources

- [VMA API](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Memory selection](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Resource creation](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`

### Memory management

- [Block allocation](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Custom pools](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Mapping and cache](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Sparse binding](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Virtual allocation](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Defragmentation](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`

### Diagnostics and visualization

- [Statistics and budget](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [JSON memory dump](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Debug annotations](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/include/vk_mem_alloc.h): `include/vk_mem_alloc.h`
- [Dump visualizer](https://github.com/gpuopen-librariesandsdks/vulkanmemoryallocator/blob/master/tools/GpuMemDumpVis/GpuMemDumpVis.py): `tools/GpuMemDumpVis/GpuMemDumpVis.py`

### Vulkan integration

- **Vulkan runtime**

### Other components

- **Engine client**

## Connections

- Engine client → VMA API: requests allocation (evidence: `README.md`)
- VMA API → Memory selection: selects memory (evidence: `README.md`)
- VMA API → Resource creation: creates resource (evidence: `README.md`)
- VMA API → Block allocation: reserves region (evidence: `README.md`)
- Resource creation → Block allocation: allocates memory (evidence: `README.md`)
- Resource creation → Vulkan runtime: creates and binds (evidence: `README.md`)
- VMA API → Custom pools: supports (evidence: `README.md`)
- VMA API → Mapping and cache: maps and flushes (evidence: `README.md`)
- VMA API → Sparse binding: allocates pages (evidence: `README.md`)
- VMA API → Virtual allocation: allocates custom data (evidence: `README.md`)
- VMA API → Defragmentation: moves allocations (evidence: `README.md`)
- VMA API → Statistics and budget: reports usage (evidence: `README.md`)
- VMA API → JSON memory dump: exports state (evidence: `README.md`)
- VMA API → Debug annotations: annotates allocations (evidence: `README.md`)
- Engine client → Dump visualizer: visualizes dump (evidence: `README.md`)
- JSON memory dump → Dump visualizer: provides JSON (evidence: `README.md`)
