From 91893ff104f00a701d6600491f2b01f28c6a6163 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Mon, 28 Dec 2020 21:30:04 +0100 Subject: [PATCH] wiiu: don't hardcode free memory --- src/core/Streaming.cpp | 2 +- src/skel/wiiu/wiiu.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 17d8d6f6..0727506b 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -222,7 +222,7 @@ CStreaming::Init2(void) desiredNumVehiclesLoaded = (int32)((ms_memoryAvailable / MB - 50) / 3 + 12); if(desiredNumVehiclesLoaded > MAXVEHICLESLOADED) desiredNumVehiclesLoaded = MAXVEHICLESLOADED; - debug("Memory allocated to Streaming is %zuMB", ms_memoryAvailable/MB); // original modifier was %d + debug("Memory allocated to Streaming is %u", ms_memoryAvailable/MB); #undef MB #endif diff --git a/src/skel/wiiu/wiiu.cpp b/src/skel/wiiu/wiiu.cpp index 76a40ac2..0b473301 100644 --- a/src/skel/wiiu/wiiu.cpp +++ b/src/skel/wiiu/wiiu.cpp @@ -13,6 +13,8 @@ #include #include +#include +#include #include #include "rwcore.h" @@ -286,8 +288,17 @@ psInitialize(void) #endif - // memory required to have all vehicles loaded - _dwMemAvailPhys = 1024*1024*170; + MEMHeapHandle heapHandle = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2); + if (heapHandle) { + _dwMemAvailPhys = MEMGetTotalFreeSizeForExpHeap(heapHandle); + } + else { + debug("Can't get heap handle"); + // fall back to hardcoded value + _dwMemAvailPhys = 1024*1024*500; + } + + debug("_dwMemAvailPhys: %u MB", _dwMemAvailPhys/1024/1024); TheText.Unload();