Added VMA_ASSERT_LEAK macro
See #385 Thanks @alecazam !
diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h
index d906e7f..3429315 100644
--- a/include/vk_mem_alloc.h
+++ b/include/vk_mem_alloc.h
@@ -2788,6 +2788,11 @@
#endif
#endif
+// Assert used for reporting memory leaks - unfreed allocations.
+#ifndef VMA_ASSERT_LEAK
+ #define VMA_ASSERT_LEAK(expr) VMA_ASSERT(expr)
+#endif
+
// If your compiler is not compatible with C++17 and definition of
// aligned_alloc() function is missing, uncommenting following line may help:
@@ -6248,7 +6253,7 @@
if (!m_AllocationList.IsEmpty())
{
- VMA_ASSERT(false && "Unfreed dedicated allocations found!");
+ VMA_ASSERT_LEAK(false && "Unfreed dedicated allocations found!");
}
}
@@ -11344,7 +11349,7 @@
m_Metadata->DebugLogAllAllocations();
// This is the most important assert in the entire library.
// Hitting it means you have some memory leak - unreleased virtual allocations.
- VMA_ASSERT(m_Metadata->IsEmpty() && "Some virtual allocations were not freed before destruction of this virtual block!");
+ VMA_ASSERT_LEAK(m_Metadata->IsEmpty() && "Some virtual allocations were not freed before destruction of this virtual block!");
vma_delete(GetAllocationCallbacks(), m_Metadata);
}
@@ -11793,7 +11798,7 @@
VmaDeviceMemoryBlock::~VmaDeviceMemoryBlock()
{
- VMA_ASSERT(m_MapCount == 0 && "VkDeviceMemory block is being destroyed while it is still mapped.");
+ VMA_ASSERT_LEAK(m_MapCount == 0 && "VkDeviceMemory block is being destroyed while it is still mapped.");
VMA_ASSERT(m_hMemory == VK_NULL_HANDLE);
}
@@ -11839,7 +11844,7 @@
m_pMetadata->DebugLogAllAllocations();
// This is the most important assert in the entire library.
// Hitting it means you have some memory leak - unreleased VmaAllocation objects.
- VMA_ASSERT(m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!");
+ VMA_ASSERT_LEAK(m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!");
VMA_ASSERT(m_hMemory != VK_NULL_HANDLE);
allocator->FreeVulkanMemory(m_MemoryTypeIndex, m_pMetadata->GetSize(), m_hMemory);
@@ -12053,7 +12058,7 @@
VmaAllocation_T::~VmaAllocation_T()
{
- VMA_ASSERT(m_MapCount == 0 && "Allocation was not unmapped before destruction.");
+ VMA_ASSERT_LEAK(m_MapCount == 0 && "Allocation was not unmapped before destruction.");
// Check if owned string was freed.
VMA_ASSERT(m_pName == VMA_NULL);