From 124e9d1d0a4804dd96a11570a106c24fe95f899c Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 13 Jul 2024 03:07:02 +0100 Subject: [PATCH] [*] Fix main process heap fragmentation caused by shared pointer blocks, always allocate from within the heap object --- Include/Aurora/Memory/Heap.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Include/Aurora/Memory/Heap.hpp b/Include/Aurora/Memory/Heap.hpp index 3224d4bc..5f709baf 100644 --- a/Include/Aurora/Memory/Heap.hpp +++ b/Include/Aurora/Memory/Heap.hpp @@ -13,6 +13,9 @@ namespace Aurora::Memory static const AuUInt8 kHeapSize = 128; static const AuUInt8 kHeap2Size = 255; + template + struct CppHeapWrapper; + struct Heap { virtual AuSPtr AllocateDivision(AuUInt32 heap, AuUInt32 alignment = 32) = 0; @@ -230,7 +233,7 @@ namespace Aurora::Memory auto pTThat = (T *)(pPtr + kAlignment); AUROXTL_COMMODITY_TRY { - return AuSPtr(pTThat, &Heap::DeleteThat); + return AuSPtr(pTThat, &Heap::DeleteThat, CppHeapWrapper { this }); } AUROXTL_COMMODITY_CATCH { @@ -340,7 +343,7 @@ namespace Aurora::Memory auto pTThat = (T *)(pPtr + kAlignment); AUROXTL_COMMODITY_TRY { - return AuSPtr(pTThat, &Heap::DeleteThatArray); + return AuSPtr(pTThat, &Heap::DeleteThatArray, CppHeapWrapper { this }); } AUROXTL_COMMODITY_CATCH {