From a4019088496a4d6b6061c755674cd7afc8b20e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= Date: Fri, 25 Sep 2020 16:06:37 +0200 Subject: [PATCH] fix: Fixed leak warning being showed when memory pools are full --- Ruffles/Memory/MemoryManager.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Ruffles/Memory/MemoryManager.cs b/Ruffles/Memory/MemoryManager.cs index a99ce96..ac0a85b 100644 --- a/Ruffles/Memory/MemoryManager.cs +++ b/Ruffles/Memory/MemoryManager.cs @@ -192,6 +192,9 @@ internal void DeAlloc(HeapMemory memory) { // Failed to enqueue memory. Queue is full if (Logging.CurrentLogLevel <= LogLevel.Warning) Logging.LogWarning("Could not return heap memory. The queue is full. The memory will be given to the garbage collector. [HEAP MEMORY]"); + + // Mark as released to prevent leak warnings. This is an intentional leak. + memory.ReleasedToGC = true; } } @@ -211,6 +214,9 @@ internal void DeAlloc(HeapPointers pointers) { // Failed to enqueue pointers. Queue is full if (Logging.CurrentLogLevel <= LogLevel.Warning) Logging.LogWarning("Could not return heap pointers. The queue is full. The memory will be given to the garbage collector. [HEAP POINTERS]"); + + // Mark as released to prevent leak warnings. This is an intentional leak. + pointers.ReleasedToGC = true; } } @@ -230,6 +236,9 @@ internal void DeAlloc(MemoryWrapper wrapper) { // Failed to enqueue pointers. Queue is full if (Logging.CurrentLogLevel <= LogLevel.Warning) Logging.LogWarning("Could not return memory wrapper. The queue is full. The memory will be given to the garbage collector. [MEMORY WRAPPER]"); + + // Mark as released to prevent leak warnings. This is an intentional leak. + wrapper.ReleasedToGC = true; } }