Give Linux a memory limit that the low-memory handling can read.

Linux overcommits, so plat_commit_enforced was 0 there and nothing the runtime does when memory runs short
ever ran: no stale-texture drops, no idle or disuse eviction. plat_commit_info on Linux now reports the
limit with the least headroom of the cgroup v2 limits the process lives under (memory.max, memory.high,
against memory.current less its file cache), the machine's RAM (MemAvailable against MemTotal) and, with
vm.overcommit_memory = 2, the commit limit; a read is reused for 250 ms and the first one is logged. The
spare VRAM blocks stand down under low memory only where device memory counts against that limit
(plat_commit_counts_vram: Windows, and any integrated GPU). Windows behaves as before.

Pull request #378 by mooki000, taken as it is. The Windows files compile; the Linux code is not compiled
or run here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 06:20:03 -05:00
parent 19eeb29cda
commit b2c5052ff5
7 changed files with 259 additions and 28 deletions

View File

@@ -105,6 +105,12 @@ the folder unless the environment sets `__GL_SHADER_DISK_CACHE_PATH`, and a limi
folder and limit; the log says which (`vk: NVIDIA's shader disk cache`). Deleting the folder costs one slow start;
`./ocarina --warm-shaders` fills it again.
The game reads the memory it may use: the limit of its cgroup v2 (`systemd-run --user --scope -p MemoryMax=16G
ocarina`, a container's) and the machine's `MemAvailable`, whichever leaves less. Linux does not fail an allocation when
memory runs short, it ends the process, so while less than the larger of 4 GB and a tenth of that limit is left the game
drops stale textures and evicts idle ones. The log names the limits at the first check (`platform: memory limits`). That
cannot give back what the game needs after its start: about 10 GB in Kokiri Forest at a 2160p game resolution.
`tools/make_appimage.py` packs this kit into one `NX2navi-Linux-<version>-x86_64.AppImage` with its own Python, for
players without a source checkout: it checks for the packages above, installs zbic with pip on its first run, picks
`--jobs` from the memory, builds into `~/Games/Ocarina` (or the folder given after the dump) and writes `play.sh`