From f7d808a426e985f03513cb3c6f9a5578f21dd963 Mon Sep 17 00:00:00 2001 From: mchughalex <25671999+mchughalex@users.noreply.github.com> Date: Tue, 21 Jul 2026 10:21:32 +0100 Subject: [PATCH] vulkan: use 64 MB VMA blocks so evicted cache memory returns to the OS --- src/ui/vulkan/vulkan_mem_alloc.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ui/vulkan/vulkan_mem_alloc.cpp b/src/ui/vulkan/vulkan_mem_alloc.cpp index 9ffc2d1..fd8ff3b 100644 --- a/src/ui/vulkan/vulkan_mem_alloc.cpp +++ b/src/ui/vulkan/vulkan_mem_alloc.cpp @@ -85,6 +85,14 @@ VmaAllocator CreateVmaAllocator(const VulkanDevice* const vulkan_device, allocator_create_info.pVulkanFunctions = &vma_vulkan_functions; allocator_create_info.instance = vulkan_instance->instance(); allocator_create_info.vulkanApiVersion = vulkan_device->properties().apiVersion; + // A VkDeviceMemory block only returns to the OS once every allocation in + // it is freed. With the 256 MB default block size, mixed-lifetime cache + // allocations keep every block partially occupied, so device memory + // freed by cache eviction stays resident for the whole session (a + // monotonic VRAM ratchet across content changes). 64 MB blocks empty and + // release far more often, while the allocation count stays orders of + // magnitude under maxMemoryAllocationCount. + allocator_create_info.preferredLargeHeapBlockSize = 64ull << 20; VmaAllocator allocator; if (vmaCreateAllocator(&allocator_create_info, &allocator) != VK_SUCCESS) { REXLOG_ERROR("Failed to create a Vulkan Memory Allocator instance");