From 6d9e7fea759a9be40b419820e950ce223597bbe2 Mon Sep 17 00:00:00 2001 From: KeatonTheBot Date: Wed, 15 Oct 2025 22:42:38 -0500 Subject: [PATCH] 12 GiB heap crash workaround Using resolution mods, heaps past 8 GiB work in some games (like LoZ: TotK) and not in others (like SMP Jamboree). Setting the heap to a hard limit of 8 GiB on the 10 & 12 GiB DRAM options seems to be the safe bet right now until a better solution is found. --- .../HOS/Kernel/Memory/KPageTableBase.cs | 24 ++++++++++++------- .../HOS/Kernel/SupervisorCall/Syscall.cs | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs index 288e25e9f..d9c45d1c5 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs @@ -201,9 +201,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory case ProcessCreationFlags.AddressSpace64BitDeprecated: aliasRegion.Size = 0x180000000; heapRegion.Size = memConfig switch { - MemoryConfiguration.MemoryConfiguration10GiB - or MemoryConfiguration.MemoryConfiguration12GiB => 0x300000000u, - _ => 0x180000000u + MemoryConfiguration.MemoryConfiguration6GiB => 0x180000000u, + MemoryConfiguration.MemoryConfiguration8GiB + or MemoryConfiguration.MemoryConfiguration10GiB + or MemoryConfiguration.MemoryConfiguration12GiB => 0x200000000u, + _ => 0x100000000u }; stackRegion.Size = 0; tlsIoRegion.Size = 0; @@ -236,9 +238,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory aliasRegion.Size = reservedAddressSpaceSize >= 0x1800000000 ? 0x1000000000 : 1UL << (addressSpaceWidth - 3); heapRegion.Size = memConfig switch { - MemoryConfiguration.MemoryConfiguration10GiB - or MemoryConfiguration.MemoryConfiguration12GiB => 0x300000000u, - _ => 0x180000000u + MemoryConfiguration.MemoryConfiguration6GiB => 0x180000000u, + MemoryConfiguration.MemoryConfiguration8GiB + or MemoryConfiguration.MemoryConfiguration10GiB + or MemoryConfiguration.MemoryConfiguration12GiB => 0x200000000u, + _ => 0x100000000u }; stackRegion.Size = 1UL << (addressSpaceWidth - 8); tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3); @@ -254,9 +258,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory { aliasRegion.Size = 0x1000000000; heapRegion.Size = memConfig switch { - MemoryConfiguration.MemoryConfiguration10GiB - or MemoryConfiguration.MemoryConfiguration12GiB => 0x300000000u, - _ => 0x180000000u + MemoryConfiguration.MemoryConfiguration6GiB => 0x180000000u, + MemoryConfiguration.MemoryConfiguration8GiB + or MemoryConfiguration.MemoryConfiguration10GiB + or MemoryConfiguration.MemoryConfiguration12GiB => 0x200000000u, + _ => 0x100000000u }; stackRegion.Size = 0x80000000; tlsIoRegion.Size = 0x1000000000; diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs index 79ddd0122..52449a35e 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs @@ -881,7 +881,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall [Svc(1)] public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size) { - if ((size & 0xfffffffd001fffff) != 0) + if ((size & 0xfffffffe001fffff) != 0) { address = 0;