From c56bc2c4d723e1acc43d17a040f824852c1c5bde Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 23 Mar 2023 23:23:47 +0200 Subject: [PATCH] SwapPage should be after loop --- Core/Memory/PhysicalMemoryManager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/Memory/PhysicalMemoryManager.cpp b/Core/Memory/PhysicalMemoryManager.cpp index c2d0495..2455824 100644 --- a/Core/Memory/PhysicalMemoryManager.cpp +++ b/Core/Memory/PhysicalMemoryManager.cpp @@ -69,12 +69,7 @@ namespace Memory if (PageBitmap[PageBitmapIndex] == true) continue; this->LockPage((void *)(PageBitmapIndex * PAGE_SIZE)); - return (void *)(PageBitmapIndex * PAGE_SIZE); - } - if (this->SwapPage((void *)(PageBitmapIndex * PAGE_SIZE))) - { - this->LockPage((void *)(PageBitmapIndex * PAGE_SIZE)); #ifdef DEBUG if (EnableExternalMemoryTracer) { @@ -97,6 +92,12 @@ namespace Memory return (void *)(PageBitmapIndex * PAGE_SIZE); } + if (this->SwapPage((void *)(PageBitmapIndex * PAGE_SIZE))) + { + this->LockPage((void *)(PageBitmapIndex * PAGE_SIZE)); + return (void *)(PageBitmapIndex * PAGE_SIZE); + } + error("Out of memory! (Free: %ldMB; Used: %ldMB; Reserved: %ldMB)", TO_MB(FreeMemory), TO_MB(UsedMemory), TO_MB(ReservedMemory)); CPU::Stop(); __builtin_unreachable();