mirror of
https://github.com/libretro/tyrquake.git
synced 2026-11-07 04:35:58 -10:00
The hunk was a fixed compile-time size (DEFAULT_MEMSIZE_MB, 8/24/32/64 MB depending on platform and whether the Vulkan RHI is built). That is a blunt instrument: too small and large mods hit Hunk_Alloc failures or thrash Cache_FreeLow; too large and constrained targets over-commit. Add an experimental environment callback, RETRO_ENVIRONMENT_GET_MEMORY_STATUS, that reports the frontend's free and total physical memory (bytes), and use it to size the hunk to the running machine. We take at most a quarter of the reported free memory, cap it at 256 MB (ample for the biggest Quake mods, and lazily committed so the reservation is cheap on virtual-memory platforms), and only ever grow above the per-platform default - never below it. The value is treated as an advisory snapshot, not a licence to allocate everything, since "free" can include reclaimable cache. Frontends that do not implement the query return false; in that case the core keeps the exact defaults it uses today, so behaviour is unchanged anywhere the callback is absent. The matching frontend side is a separate RetroArch change wiring the call to frontend_driver_get_free_memory().