The Vulkan® Memory Allocator (VMA) library provides a simple and easy to integrate API to help you allocate memory for Vulkan® buffer and image storage.
Download the latest version - v3.3.0
This release contains the following:
- Added function vmaImportVulkanFunctionsFromVolk, useful for loading pointers to Vulkan functions with volk library.
Other changes:
- Added macro ‘VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE’ with default value 1.
- Changed macro ‘VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT’ default value from 0 to 1.
- Added documentation chapter “Frequently asked questions”.
- Other fixes and improvements, including compatibility with various platforms and compilers.
Benefits
The library is battle-ready, and integrated into the majority of Vulkan® game titles on PC, as well as the Google Filament rendering engine, the official Khronos® Group Vulkan® Samples, and many other open source projects for Android™, Linux, MacOS, and Windows®.
This library can help game developers to manage memory allocations and resource creation by offering some higher-level functions:
- Functions that help to choose correct and optimal memory type based on intended usage of the memory.
- Required or preferred traits of the memory are expressed using higher-level description comparing to Vulkan flags.
- Functions that allocate memory blocks, reserve and return parts of them (
VkDeviceMemory
+ offset + size) to the user.
- Library keeps track of allocated memory blocks, used and unused ranges inside them, finds best matching unused ranges for new allocations, respects all the rules of alignment and buffer/image granularity.
- Functions that can create an image/buffer, allocate memory for it and bind them together – all in one call.
Additional features
- Self-contained C++ library in single header file. No external dependencies other than the standard C and C++ library and Vulkan.
- Public interface in C, in same convention as Vulkan API. Implementation in C++.
- Platform-independent, but developed and tested on Windows using Visual Studio. Continuous integration setup for Windows and Linux. Used also on Android, MacOS, and other platforms.
- Support for memory mapping, reference-counted internally.
- Support for persistently mapped memory: Just allocate with appropriate flag and access the pointer to already mapped memory.
- Linear allocator: Create a pool with linear algorithm and use it for much faster allocations and deallocations in free-at-once, stack, double stack, or ring buffer fashion.
- Defragmentation of GPU and CPU memory: Let the library move data around to free some memory blocks and make your allocations better compacted.
- Statistics: Obtain brief or detailed statistics about the amount of memory used, unused, number of allocated blocks, number of allocations etc. - globally, per memory heap, and per memory type.
- Debug annotations: Associate custom void* pUserData and debug char* pName with each allocation.
- JSON dump: Output a JSON string with detailed map of internal state, including allocations, their string names, and gaps between them.
- Convert JSON dump into a picture to visualize your memory.
- Support for interoperability with OpenGL.
- Virtual allocator: Interface for using core allocation algorithm to allocate any custom data, e.g. pieces of one large buffer.
I can let VMA handle all the hard work and do a better job than I would. On top of that it still lets me easily drop down to raw Vulkan when I need the finest control for something specific. You should absolutely use VMA for your general memory allocation needs in Vulkan, even when you do need something special it will probably do that for you or make it easy to write some special case code.
Baldur Karlsson
Creator, RenderDoc
We integrated AMD’s Vulkan Memory Allocator (VMA) and never looked back.
Jean-Noe Morissette
Software Architect, Ubisoft
My experience with VMA (…) was that it let you have as much or little control as you wanted. Made Vulkan feel more like D3D11 unless you really wanted to think about heaps. I am doing another Vk project soon and plan to use it.
Timothy Lochner
Senior Engine Architect, Rightware Inc.