From f362e33293ebd8b5dcb2e9556f5c96eeb2e77e50 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 09e93962b..92936093b 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs @@ -197,9 +197,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; @@ -231,9 +233,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory aliasRegion.Size = 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); @@ -249,9 +253,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 b9d3b7614..dba46bf54 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;