Play: the kept RAM's hard minimum is let go before the PC runs out #2638

Open
github-bot wants to merge 4 commits from github-bot/gh-2638 into main AGit
Owner

@⁠unueberlegt on GitHub · 2026-11-29 15:21 UTC · original
unueberlegt:fix/keep-ram-self-disarm → main · +128 −5 · 1 files · 4 commits · open

What this changes

VICTORY_KEEP_RAM_GB's hard working-set minimum keeps its guarantee, but:

  • the maximum is soft again (QUOTA_LIMITS_HARDWS_MAX_DISABLE is no longer set): under pressure the memory manager may trim the set back to it, where before the process could claim the whole PC;
  • while the game runs, a thread watches the PC's free memory, and under 2 GB the hard minimum is let go — once, and a line says so. After that the game is trimmed as it would be without the switch;
  • a start asking for more than half the PC's memory says what that costs.

Why

The hard minimum is held even as the game's commit grows past what the PC can hold. Measured on an RTX 5070 12 GB / 31 GB PC, Series X, 1440p, DLSS Quality, FG 2× (#2464's §3): with 20 GB kept, the PC fell to 980 MB free, 202 host allocations were refused (0x8007000E), and the game died 4 minutes 49 seconds in — reading through a NULL pointer in VCRUNTIME140's copy loop, called from its own code, its crash handler taking the process down. The same run without the switch survives the same exhaustion as a zombie at 3 fps with 297 refused allocations: the difference the minimum makes is that nothing can be given back, so a failing allocation fails fatally in code that (a console title) has no out-of-memory path. #2464's reporter lost the device instead of the title — their 32 GB of page file kept the host's allocations alive, and the pressure landed on the card's residency.

The switch's own case (Windows cutting the working set from 15 GB to 2 GB at once, the game at half speed for minutes) is untouched: the minimum is kept as long as the PC can spare it.

Testing

  • New the_hard_minimum_is_let_go_when_the_pc_runs_out: the threshold's edges.
  • Measured, as above: dead 4:49 with 20 GB kept; 27 minutes alive without it; the disarm fires at the 515 MB–1 GB dips the kept run reaches before it dies.

Part of #2464 (its §3; §2 — the PC exhausting without the switch — is measured and reported there: 48 GB committed, ~300 refusals, 3 fps on this PC).

🤖 Generated with Claude Code

**@⁠unueberlegt** on GitHub · 2026-11-29 15:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2638) `unueberlegt:fix/keep-ram-self-disarm` → `main` · +128 −5 · 1 files · 4 commits · open ## What this changes `VICTORY_KEEP_RAM_GB`'s hard working-set minimum keeps its guarantee, but: - the maximum is soft again (`QUOTA_LIMITS_HARDWS_MAX_DISABLE` is no longer set): under pressure the memory manager may trim the set back to it, where before the process could claim the whole PC; - while the game runs, a thread watches the PC's free memory, and under 2 GB the hard minimum is let go — once, and a line says so. After that the game is trimmed as it would be without the switch; - a start asking for more than half the PC's memory says what that costs. ## Why The hard minimum is held even as the game's commit grows past what the PC can hold. Measured on an RTX 5070 12 GB / 31 GB PC, Series X, 1440p, DLSS Quality, FG 2× (#2464's §3): with 20 GB kept, the PC fell to 980 MB free, 202 host allocations were refused (`0x8007000E`), and the game died 4 minutes 49 seconds in — reading through a NULL pointer in VCRUNTIME140's copy loop, called from its own code, its crash handler taking the process down. The same run without the switch survives the same exhaustion as a zombie at 3 fps with 297 refused allocations: the difference the minimum makes is that nothing can be given back, so a failing allocation fails fatally in code that (a console title) has no out-of-memory path. #2464's reporter lost the device instead of the title — their 32 GB of page file kept the host's allocations alive, and the pressure landed on the card's residency. The switch's own case (Windows cutting the working set from 15 GB to 2 GB at once, the game at half speed for minutes) is untouched: the minimum is kept as long as the PC can spare it. ## Testing - New `the_hard_minimum_is_let_go_when_the_pc_runs_out`: the threshold's edges. - Measured, as above: dead 4:49 with 20 GB kept; 27 minutes alive without it; the disarm fires at the 515 MB–1 GB dips the kept run reaches before it dies. Part of #2464 (its §3; §2 — the PC exhausting without the switch — is measured and reported there: 48 GB committed, ~300 refusals, 3 fps on this PC). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
VICTORY_KEEP_RAM_GB's hard working-set minimum is held even as the game's
commit grows past what the PC can hold: its free memory falls to nothing,
host allocations fail, and the game dies of it (RTX 5070 12 GB, 31 GB
RAM, 20 GB kept: the PC at 980 MB free, 43 GB committed, 202 host
allocations refused, and a NULL read out of the title's own code 4
minutes 49 seconds in; #2464's reporter lost the device the same way, its
32 GB of page file kept the host's own allocations alive). The maximum
stays soft now, where QUOTA_LIMITS_HARDWS_MAX_DISABLE forbade trimming it
back; and a thread watches the PC's free memory, letting the hard minimum
go under 2 GB free — once, and said so — before the PC runs out.

Co-Authored-By: Claude Code <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 15:25:07 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 15:40 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-29 15:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2638#issuecomment-7258270176) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.
Author
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 08:34 UTC · original

I reproduced two Win32 failures in the working-set setup and disarm paths of this PR.

  • With min = max = 256 MiB and flag 0x1, SetProcessWorkingSetSizeEx returned ERROR_INVALID_PARAMETER (87). The hard minimum was never installed on this machine.
  • With a 256 MiB minimum and 512 MiB maximum, install succeeded. The original disarm flags 0x4 | 0x8 also returned 87 and the reported flags stayed 0x9. Those two bits control the maximum in opposite directions.

Follow-up commit 0358b98, based on b82884e, keeps distinct sizes and uses only QUOTA_LIMITS_HARDWS_MIN_DISABLE (0x2). In the same Windows probe, the corrected call succeeded, flags changed from 0x9 to 0xA, and the guard proposed on #3749 detected the release. The watcher now reports a failed call and retries at the next low-RAM sample. The existing threshold test and staged asset-policy check passed. The API probe ran in a disposable process without the title.

**@⁠tyr0nsur** on GitHub · 2026-11-30 08:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2638#issuecomment-7273084950) I reproduced two Win32 failures in the working-set setup and disarm paths of this PR. - With `min = max = 256 MiB` and flag `0x1`, `SetProcessWorkingSetSizeEx` returned `ERROR_INVALID_PARAMETER` (87). The hard minimum was never installed on this machine. - With a 256 MiB minimum and 512 MiB maximum, install succeeded. The original disarm flags `0x4 | 0x8` also returned 87 and the reported flags stayed `0x9`. Those two bits control the maximum in opposite directions. [Follow-up commit `0358b98`](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/0358b98f3a7ac470e3ed8adfaf367c74af2ba308), based on `b82884e`, keeps distinct sizes and uses only `QUOTA_LIMITS_HARDWS_MIN_DISABLE` (`0x2`). In the same Windows probe, the corrected call succeeded, flags changed from `0x9` to `0xA`, and the guard proposed on #3749 detected the release. The watcher now reports a failed call and retries at the next low-RAM sample. The existing threshold test and staged asset-policy check passed. The API probe ran in a disposable process without the title.
Windows can reject equal working set sizes with ERROR_INVALID_PARAMETER.
Keep distinct sizes when setting and releasing the hard minimum. Disable
only the minimum, using QUOTA_LIMITS_HARDWS_MIN_DISABLE, so the maximum's
policy is preserved. Log an unsuccessful release and retry on the next
low-memory sample.

(cherry picked from commit 0358b98f3a7ac470e3ed8adfaf367c74af2ba308)
Co-Authored-By: Claude Code <[email protected]>
keep_ram's install follows our probe-verified form (distinct sizes,
only QUOTA_LIMITS_HARDWS_MIN_ENABLE); main's apply_defaults for the
standalone launcher runs slots in after the watch.

Co-Authored-By: Claude Code <[email protected]>
Author
Owner

@⁠unueberlegt on GitHub · 2026-12-01 08:42 UTC · original

Thanks for the reproduction and for pinning both failures down — the analysis was exactly right, and the fix is now on the branch.

Your 0358b98 is cherry-picked onto fix/keep-ram-self-disarm (authorship kept): distinct sizes on install and release (max = min * 2), only QUOTA_LIMITS_HARDWS_MIN_ENABLE on the way in and QUOTA_LIMITS_HARDWS_MIN_DISABLE on the way out, and a failed release is now logged and retried at the next low-RAM sample instead of silently ending the watch. The branch also carries a merge of current main, so it is MERGEABLE again.

@⁠dyshay, one note for the janus-prs runs: they exercised the pre-fix form. Depending on the machine, either the hard minimum never installed (ERROR_INVALID_PARAMETER with equal sizes, so the run measured effectively no switch), or it installed and the broken disarm flags left it hard for the rest of the run — the case this PR exists for. If the queued RTX 4090 runs have not happened yet, a re-run against the updated branch would measure the switch as it is meant to work.

**@⁠unueberlegt** on GitHub · 2026-12-01 08:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2638#issuecomment-7305665611) Thanks for the reproduction and for pinning both failures down — the analysis was exactly right, and the fix is now on the branch. Your `0358b98` is cherry-picked onto `fix/keep-ram-self-disarm` (authorship kept): distinct sizes on install and release (`max = min * 2`), only `QUOTA_LIMITS_HARDWS_MIN_ENABLE` on the way in and `QUOTA_LIMITS_HARDWS_MIN_DISABLE` on the way out, and a failed release is now logged and retried at the next low-RAM sample instead of silently ending the watch. The branch also carries a merge of current main, so it is MERGEABLE again. @⁠dyshay, one note for the `janus-prs` runs: they exercised the pre-fix form. Depending on the machine, either the hard minimum never installed (`ERROR_INVALID_PARAMETER` with equal sizes, so the run measured effectively no switch), or it installed and the broken disarm flags left it hard for the rest of the run — the case this PR exists for. If the queued RTX 4090 runs have not happened yet, a re-run against the updated branch would measure the switch as it is meant to work.
This pull request has changes conflicting with the target branch.
  • apps/victory/src/play.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2638/head:github-bot/gh-2638'
git switch 'github-bot/gh-2638'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2638'
git switch 'github-bot/gh-2638'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2638'
git switch 'github-bot/gh-2638'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2638'
git switch 'main'
git merge --squash 'github-bot/gh-2638'
git switch 'main'
git merge --ff-only 'github-bot/gh-2638'
git switch 'main'
git merge 'github-bot/gh-2638'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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
github/trustno1-coder--VIctory-NVIDIA!2638
No description provided.