[PR #441] [MERGED] runtime: honor LEONIDA_TITLE_MEMORY_MB in XSystemGetAppMemoryUsageLimit and XMemGetWorkingSetStatistics (RT-TITLE-MEMORY-CAP) #491

Closed
opened 2026-11-26 20:18:03 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/441
Author: @jujumoneylol
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: pr/title-memory-cap


📝 Commits (2)

  • 6c1d939 runtime: honor LEONIDA_TITLE_MEMORY_MB in XSystemGetAppMemoryUsageLimit and XMemGetWorkingSetStatistics
  • 6cb16a4 docs: document LEONIDA_TITLE_MEMORY_MB in runtime/README.md

📊 Changes

5 files changed (+93 additions, -2 deletions)

View changed files

📝 runtime/README.md (+2 -1)
📝 runtime/shims/xgameruntime.cpp (+16 -1)
📝 runtime/shims/xmem.cpp (+15 -0)
📝 runtime/test/xgameruntime_test.cpp (+31 -0)
📝 runtime/test/xmem_test.cpp (+29 -0)

📄 Description

Claimed in the coordination issue as: RT-TITLE-MEMORY-CAP (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122816234)

What and why

Implements @KoLolX3's finding in #14: both XSystemGetAppMemoryUsageLimit (runtime/shims/xgameruntime.cpp) and XMemGetWorkingSetStatistics (runtime/shims/xmem.cpp) previously always reported total host physical RAM (ullTotalPhys), causing memory-constrained hosts (16 GB systems or cgroup-capped runs) to tell the title it has more memory than it can safely allocate.

  • Honors LEONIDA_TITLE_MEMORY_MB in both XSystemGetAppMemoryUsageLimit() and XMemGetWorkingSetStatistics() (total memory at +0).
  • Clamps valid positive integer values to 2048..65536 MiB (2 GiB..64 GiB).
  • Strictly ignores unset, empty, negative, overflowing, non-numeric, or trailing-garbage values (falling back to GlobalMemoryStatusEx().ullTotalPhys / 12 GiB fallback unchanged).
  • Adds unit tests for default, valid override (6144), lower/upper clamping (512 → 2048, 131072 → 65536), and malformed values in runtime/test/xgameruntime_test.cpp and runtime/test/xmem_test.cpp.

Tested

  • Built xgameruntime_test and xmem_test with MSVC 19.44 (vcvars64) + Ninja on top of main 8f481cf16.
  • xgameruntime_test: OK (166 checks).
  • xmem_test: OK (222 checks).
  • py -3.13 -I scripts/check_no_game_data.py runtime/shims/xgameruntime.cpp runtime/shims/xmem.cpp runtime/test/xgameruntime_test.cpp runtime/test/xmem_test.cpp: clean.

GPUs tested: n/a (CPU-only runtime shim & unit tests on Windows 11 26200)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — runtime shim only)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/441 **Author:** [@jujumoneylol](https://github.com/jujumoneylol) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `pr/title-memory-cap` --- ### 📝 Commits (2) - [`6c1d939`](https://github.com/ubiquitarianism/leonida/commit/6c1d939509241e145f73fd41a22aacc1dd2f80e6) runtime: honor LEONIDA_TITLE_MEMORY_MB in XSystemGetAppMemoryUsageLimit and XMemGetWorkingSetStatistics - [`6cb16a4`](https://github.com/ubiquitarianism/leonida/commit/6cb16a4fa8fdcdbc9d381280d75e63d046f03d1e) docs: document LEONIDA_TITLE_MEMORY_MB in runtime/README.md ### 📊 Changes **5 files changed** (+93 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/README.md` (+2 -1) 📝 `runtime/shims/xgameruntime.cpp` (+16 -1) 📝 `runtime/shims/xmem.cpp` (+15 -0) 📝 `runtime/test/xgameruntime_test.cpp` (+31 -0) 📝 `runtime/test/xmem_test.cpp` (+29 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-TITLE-MEMORY-CAP (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122816234) ### What and why Implements @KoLolX3's finding in #14: both `XSystemGetAppMemoryUsageLimit` (`runtime/shims/xgameruntime.cpp`) and `XMemGetWorkingSetStatistics` (`runtime/shims/xmem.cpp`) previously always reported total host physical RAM (`ullTotalPhys`), causing memory-constrained hosts (16 GB systems or cgroup-capped runs) to tell the title it has more memory than it can safely allocate. - Honors `LEONIDA_TITLE_MEMORY_MB` in both `XSystemGetAppMemoryUsageLimit()` and `XMemGetWorkingSetStatistics()` (total memory at `+0`). - Clamps valid positive integer values to `2048..65536` MiB (`2 GiB..64 GiB`). - Strictly ignores unset, empty, negative, overflowing, non-numeric, or trailing-garbage values (falling back to `GlobalMemoryStatusEx().ullTotalPhys` / 12 GiB fallback unchanged). - Adds unit tests for default, valid override (`6144`), lower/upper clamping (`512` → `2048`, `131072` → `65536`), and malformed values in `runtime/test/xgameruntime_test.cpp` and `runtime/test/xmem_test.cpp`. ### Tested - Built `xgameruntime_test` and `xmem_test` with MSVC 19.44 (`vcvars64`) + Ninja on top of `main` `8f481cf16`. - `xgameruntime_test`: OK (166 checks). - `xmem_test`: OK (222 checks). - `py -3.13 -I scripts/check_no_game_data.py runtime/shims/xgameruntime.cpp runtime/shims/xmem.cpp runtime/test/xgameruntime_test.cpp runtime/test/xmem_test.cpp`: clean. GPUs tested: n/a (CPU-only runtime shim & unit tests on Windows 11 26200) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — runtime shim only) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:03 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#491
No description provided.