d3d12: warn on screen when Windows is low on commit memory (D3D12-LOW-COMMIT-WARNING) #3408

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "+refs/pull/3408/head:oreofr/low-commit-warning"
git switch "oreofr/low-commit-warning"
Open
leonida/mandy
OreoFR wants to merge 1 commit from oreofr/low-commit-warning into main AGit

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3408/head:oreofr/low-commit-warning'
git switch 'oreofr/low-commit-warning'
Member

Item: D3D12-LOW-COMMIT-WARNING (claimed in #3312).

What

When Windows has less than LEONIDA_LOW_COMMIT_MB megabytes left to commit (ullAvailPageFile; default 2048, 0 turns it off), the player sees a three-line box at the top left of the picture:

WARNING: Windows is almost out of memory (commit). The game may close.
Close other apps, or set a larger or system-managed page file.
See d3d12/docs/windows-memory.md. LEONIDA_LOW_COMMIT_MB=0 hides this.
  • Shown for 30 s, again every 5 min while commit stays low.
  • Hysteresis: clears only once commit is back 512 MB above the floor; at most one change every 10 s, so a figure hovering at the floor does not flicker.
  • One log line when it appears (warn, Windows is almost out of commit ..., with free_commit_mb/floor_mb) and one when it clears (info).
  • Cheap: no query of its own. residency::refresh (the once-a-second sweep) hands it the ullAvailPageFile it already reads.

How (reuse, no new UI)

Drawn through the existing Lua mods' overlay (leonida_menu::overlay, laid over the picture by host/trainer.rs in every build, not only diagnostics). New overlay::notice(cmds): a second list drawn over the mods' list, painted only when it changes; the mods' list gives way at the command cap so the notice stays whole. With no mod running, the notice alone sets LUA_DRAW.

Files: leonida-gpu/src/low_commit.rs (new), residency.rs (one call), lib.rs, leonida-menu/src/overlay.rs, d3d12/docs/windows-memory.md, d3d12/docs/switches.md (regenerated).

Why

Players on 16-32 GB of RAM crash when Windows' commit runs out, with no hint why; we already tracked the figure but showed nothing.

Credit

After Darner (TrustNo1/Darner, GPL-3.0-or-later) commit 8f19e38 (DARNER_LOW_COMMIT_MB, 2048, on). Their version says it once a run; this one adds hysteresis and a 5-minute reminder.

Tests

  • cargo test -p leonida-gpu low_commit: 6 tests (floor/switch parsing and 0 = off, threshold, hysteresis, rate limit under a swinging figure, 30 s / 5 min cycle, notice layout). Red/green: with CLEAR_ABOVE = 0 and CHANGE_EVERY = 0 the 3 hysteresis/rate tests fail; green with the real values.
  • cargo test -p leonida-menu overlay: 7 tests incl. 2 new (notice alone, over the mods, outliving their list, cleared; full mod list gives way).
  • cargo test -p leonida-gpu -p leonida-menu -p leonida-lua, cargo clippy -p leonida-gpu -p leonida-menu --all-targets (no findings), cargo build --profile diag -p leonida links.
  • python -I tests/test_d3d12_switches.py, python -I tests/test_docs_links.py, python -I scripts/check_no_game_data.py on the changed files: OK.

In-game check pending (quick trigger: LEONIDA_LOW_COMMIT_MB=999999 shows it within the first seconds of the world).

AI-assisted (Claude Code). No GPU run; Windows 11, RTX 4070 machine, not launched.

🤖 Generated with Claude Code

Item: **D3D12-LOW-COMMIT-WARNING** (claimed in #3312). ## What When Windows has less than `LEONIDA_LOW_COMMIT_MB` megabytes left to commit (`ullAvailPageFile`; default **2048**, `0` turns it off), the player sees a three-line box at the top left of the picture: ``` WARNING: Windows is almost out of memory (commit). The game may close. Close other apps, or set a larger or system-managed page file. See d3d12/docs/windows-memory.md. LEONIDA_LOW_COMMIT_MB=0 hides this. ``` - Shown for 30 s, again every 5 min while commit stays low. - Hysteresis: clears only once commit is back 512 MB above the floor; at most one change every 10 s, so a figure hovering at the floor does not flicker. - One log line when it appears (`warn`, `Windows is almost out of commit ...`, with `free_commit_mb`/`floor_mb`) and one when it clears (`info`). - Cheap: no query of its own. `residency::refresh` (the once-a-second sweep) hands it the `ullAvailPageFile` it already reads. ## How (reuse, no new UI) Drawn through the existing Lua mods' overlay (`leonida_menu::overlay`, laid over the picture by `host/trainer.rs` in every build, not only `diagnostics`). New `overlay::notice(cmds)`: a second list drawn over the mods' list, painted only when it changes; the mods' list gives way at the command cap so the notice stays whole. With no mod running, the notice alone sets `LUA_DRAW`. Files: `leonida-gpu/src/low_commit.rs` (new), `residency.rs` (one call), `lib.rs`, `leonida-menu/src/overlay.rs`, `d3d12/docs/windows-memory.md`, `d3d12/docs/switches.md` (regenerated). ## Why Players on 16-32 GB of RAM crash when Windows' commit runs out, with no hint why; we already tracked the figure but showed nothing. ## Credit After Darner (TrustNo1/Darner, GPL-3.0-or-later) commit 8f19e38 (`DARNER_LOW_COMMIT_MB`, 2048, on). Their version says it once a run; this one adds hysteresis and a 5-minute reminder. ## Tests - `cargo test -p leonida-gpu low_commit`: 6 tests (floor/switch parsing and `0` = off, threshold, hysteresis, rate limit under a swinging figure, 30 s / 5 min cycle, notice layout). Red/green: with `CLEAR_ABOVE = 0` and `CHANGE_EVERY = 0` the 3 hysteresis/rate tests fail; green with the real values. - `cargo test -p leonida-menu overlay`: 7 tests incl. 2 new (notice alone, over the mods, outliving their list, cleared; full mod list gives way). - `cargo test -p leonida-gpu -p leonida-menu -p leonida-lua`, `cargo clippy -p leonida-gpu -p leonida-menu --all-targets` (no findings), `cargo build --profile diag -p leonida` links. - `python -I tests/test_d3d12_switches.py`, `python -I tests/test_docs_links.py`, `python -I scripts/check_no_game_data.py` on the changed files: OK. **In-game check pending** (quick trigger: `LEONIDA_LOW_COMMIT_MB=999999` shows it within the first seconds of the world). AI-assisted (Claude Code). No GPU run; Windows 11, RTX 4070 machine, not launched. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
When Windows has less than LEONIDA_LOW_COMMIT_MB megabytes left to commit
(default 2048; 0 turns it off), a three-line notice is laid over the picture
for 30 s, through the Lua mods' overlay (leonida_menu::overlay::notice, a new
slot drawn over the mods' list, in every build), and again every 5 min while
commit stays low. It clears once commit is 512 MB above the floor again;
changes at most once every 10 s; one log line when it appears and when it
clears. No query of its own: residency::refresh hands it the ullAvailPageFile
it already reads once a second.

After Darner (TrustNo1/Darner, GPL-3.0-or-later) commit 8f19e38
(DARNER_LOW_COMMIT_MB, 2048, on).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OreoFR referenced this pull request from a commit 2026-12-04 02:26:46 +00:00
First-time contributor

Independent local verification of this change (I changed no code).

  • Head 41e56ebf, merge base 52861466. All eight new tests are absent on the base: git grep -F <test> 52861466 -- <path> -> exit 1 for each.
  • On the PR head, with module-qualified names, -- --exact and a private CARGO_TARGET_DIR, all eight passed: six low_commit::tests::* in leonida-gpu (the_floor_is_the_switch_or_the_default_and_zero_is_off, under_the_floor_it_shows_and_above_it_nothing, it_clears_only_above_the_floor_and_the_margin, a_figure_swinging_across_both_lines_changes_at_most_every_ten_seconds, while_it_stays_low_it_is_shown_for_a_while_and_again_later, the_notice_is_a_box_with_every_line_inside_it) and two overlay::tests::* in leonida-menu (the_notice_shows_alone_and_over_the_mods_and_outlives_their_lists, a_full_mod_list_gives_way_to_the_notice).
  • git diff --check 52861466 41e56ebf -> clean. python -I scripts/check_no_game_data.py on the six changed files -> clean.

GPUs tested: none (synthetic counter/geometry inputs, no device-gated test counted). Driver: n/a (Windows commit-memory is read from synthetic values here). No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.

Independent local verification of this change (I changed no code). - Head `41e56ebf`, merge base `52861466`. All eight new tests are absent on the base: `git grep -F <test> 52861466 -- <path>` -> exit 1 for each. - On the PR head, with module-qualified names, `-- --exact` and a private `CARGO_TARGET_DIR`, all eight passed: six `low_commit::tests::*` in `leonida-gpu` (`the_floor_is_the_switch_or_the_default_and_zero_is_off`, `under_the_floor_it_shows_and_above_it_nothing`, `it_clears_only_above_the_floor_and_the_margin`, `a_figure_swinging_across_both_lines_changes_at_most_every_ten_seconds`, `while_it_stays_low_it_is_shown_for_a_while_and_again_later`, `the_notice_is_a_box_with_every_line_inside_it`) and two `overlay::tests::*` in `leonida-menu` (`the_notice_shows_alone_and_over_the_mods_and_outlives_their_lists`, `a_full_mod_list_gives_way_to_the_notice`). - `git diff --check 52861466 41e56ebf` -> clean. `python -I scripts/check_no_game_data.py` on the six changed files -> clean. GPUs tested: none (synthetic counter/geometry inputs, no device-gated test counted). Driver: n/a (Windows commit-memory is read from synthetic values here). No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.
First-time contributor

RUN — In-game & Test Gate (NVIDIA RTX 5070 12 GB, Windows 11)

Tested PR head 41e56ebff9 merged cleanly onto main (f22b9fa64), diagnostic release build (-SeriesS, no frame generation, 315 s automated run from the same save), compared against our recent main (30c683055) baseline:

Metric main baseline (30c683055) PR #3408 (41e56ebff9)
World samples (>=1000 draws) 36 (max_draws=5187) 36 (max_draws=5152)
Median FPS / frame time 23.0 fps (43.5 ms) 24.4 fps (40.9 ms)
Slowest 10% / fastest 10% 13.7 / 25.0 fps 14.9 / 25.4 fps
3000-4999 draws/frame median 23.2 fps (28 samples) 24.8 fps (26 samples)
Errors / warnings / device lost 0 / 0 / 0 0 / 0 / 0

Unit & Repo Checks

  • cargo test -p leonida-gpu --lib --locked residency:: — 3/3 PASS
  • cargo clippy -p leonida-gpu --all-targets --locked -- -D warnings — 0 warnings
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md — PASS
  • python -I scripts/check_no_game_data.py — PASS

Verdict

PASS — clean merge onto f22b9fa64, clippy/switch/residency checks pass, and the 315 s in-game run completed cleanly with zero errors/warnings and no regression. Ready for merge.

AI-assisted.

### RUN — In-game & Test Gate (NVIDIA RTX 5070 12 GB, Windows 11) Tested PR head `41e56ebff9` merged cleanly onto `main` (`f22b9fa64`), diagnostic release build (`-SeriesS`, no frame generation, 315 s automated run from the same save), compared against our recent `main` (`30c683055`) baseline: | Metric | `main` baseline (`30c683055`) | PR `#3408` (`41e56ebff9`) | | --- | --- | --- | | World samples (`>=1000` draws) | `36` (`max_draws=5187`) | `36` (`max_draws=5152`) | | Median FPS / frame time | `23.0 fps` (`43.5 ms`) | `24.4 fps` (`40.9 ms`) | | Slowest 10% / fastest 10% | `13.7` / `25.0 fps` | `14.9` / `25.4 fps` | | `3000-4999` draws/frame median | `23.2 fps` (`28` samples) | `24.8 fps` (`26` samples) | | Errors / warnings / device lost | `0` / `0` / `0` | `0` / `0` / `0` | ### Unit & Repo Checks - `cargo test -p leonida-gpu --lib --locked residency::` — `3/3` PASS - `cargo clippy -p leonida-gpu --all-targets --locked -- -D warnings` — `0` warnings - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` — PASS - `python -I scripts/check_no_game_data.py` — PASS ### Verdict **PASS** — clean merge onto `f22b9fa64`, `clippy`/switch/residency checks pass, and the 315 s in-game run completed cleanly with zero errors/warnings and no regression. Ready for merge. AI-assisted.
Sign in to join this conversation.
No description provided.