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();