From 7f61dfdb8dde7a46f6856a96c4de95a104ddc405 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 17 Oct 2023 11:25:35 -0700 Subject: [PATCH] pm: since 15.0.0, WaitApplicationMemoryAvailable is more lenient --- stratosphere/pm/source/impl/pm_resource_manager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stratosphere/pm/source/impl/pm_resource_manager.cpp b/stratosphere/pm/source/impl/pm_resource_manager.cpp index fc07a5daa..f11a72dca 100644 --- a/stratosphere/pm/source/impl/pm_resource_manager.cpp +++ b/stratosphere/pm/source/impl/pm_resource_manager.cpp @@ -170,10 +170,18 @@ namespace ams::pm::resource { } void WaitApplicationMemoryAvailable() { + /* Get firmware version. */ + const auto fw_ver = hos::GetVersion(); + + /* On 15.0.0+, pm considers application memory to be available if there is exactly 96 MB outstanding. */ + /* This is probably because this corresponds to the gameplay-recording memory. */ + constexpr u64 AllowedUsedApplicationMemory = 96_MB; + + /* Wait for memory to be available. */ u64 value = 0; while (true) { R_ABORT_UNLESS(svc::GetSystemInfo(&value, svc::SystemInfoType_UsedPhysicalMemorySize, svc::InvalidHandle, svc::PhysicalMemorySystemInfo_Application)); - if (value == 0) { + if (value == 0 || (fw_ver >= hos::Version_15_0_0 && value == AllowedUsedApplicationMemory)) { break; } os::SleepThread(TimeSpan::FromMilliSeconds(1));