d3d12: memory grows without bound while driving on a 64 GB / 32 GB machine; texture-pool blocks are never given back #3261

Open
opened 2026-12-02 23:12:41 +00:00 by x2Tweek · 3 comments
x2Tweek commented 2026-12-02 23:12:41 +00:00 (Migrated from github.com)
Contributor

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-02T23:12:41Z.


What happens

On a high-RAM, high-VRAM machine, the process keeps growing for as long as the player moves through the world:
private bytes, Windows commit and card memory. Nothing gives the memory back. In a session of 10 to 15 minutes,
commit headroom falls toward zero. From there the runtime limits texture prefetch, stutters get worse, roads
show missing textures, and a crash follows if the session goes on. Restarting the game is the only workaround.

The numbers below are from the runtime's own copystat memory lines and census lines, over several runs on
2026-12-02.

Growth over one session (city driving, hardware RT on):

run private bytes commit left (Windows) host textures alive card memory in use
A, 12 min 12 GB → 58 GB 59 GB → 12.6 GB 214k / 17 GB 2 GB → 28.5 GB of 31.4
B, 5.5 min 10.9 GB → 43.4 GB 36.9 GB → 5.2 GB 164k / 13.9 GB 1.9 GB → 20.7 GB
C, 8 min → 45 GB → 1.2 GB 167k / 13.6 GB 22.5 GB
D, ~8 min → 52.5 GB → 13.0 GB 257k / 17.2 GB 24.4 GB

That is about +1 GB of commit a minute while driving, and it never comes back down.

  • Correction (edited): another game (Black Desert) was running on the same PC during these runs and the ones in the comments below. The private bytes, host textures and card memory in the table are the runtime's own process counters (GetProcessMemoryInfo, DXGI QueryVideoMemoryInfo), so they do not include it. The Windows commit headroom is system-wide, so it is lower than on an otherwise idle PC by what that game held, and the card's budget the runtime saw fell from 31.4 GB to about 24.7 GB as VRAM filled, part of which is that game's share.

Where it sits (the census line at the end of runs B and D):

pool.rs  blocks of textures   11712 MB in 183   (run D: 14976 MB in 234)
pool.rs  textures in blocks   10914 MB in 162550 (run D: 14145 MB in 256020)
shadow.rs shared buffers in blocks 2524 MB in 631 (run D: 4948 MB in 1237)

The 64 MiB DEFAULT texture blocks make up the bulk, and they only grow.

What exists today, and why it is not enough here:

  • LEONIDA_REAPER=1 (with LEONIDA_REAPER_LIMIT): on this machine, commit headroom still fell from 28.9 GB to
    6.9 GB in 15 minutes. In earlier builds it crashed after about 8 minutes. Retried tonight on the build below with
    DLSS on: the device was lost about 50 s into the world (device removed, 0x887A0006). The same build and settings
    without the reaper then ran 8 minutes with no device loss. That is one run each, so not proof. So I run with
    LEONIDA_REAPER=0, and the table above is with it off.
  • #3201 (commit-aware texture pool, LEONIDA_COMMIT_FLOOR on): I tested it in game (comment there). Once
    headroom fell to about 4.5 GB, it did let go of idle textures, 184k → 24k. But the 64 MiB blocks stayed:
    192 blocks, 12.3 GB, holding 2.1 GB of live textures. So private bytes, commit and card memory kept their trend.

Suggestion: give back texture blocks (and shared-buffer blocks) once they are empty or nearly empty, or
compact them, driven by the same commit floor. Or cap the pool's block count by the card's budget on cards where
VRAM is not the limit but commit is.

Commit

Upstream main 0d7a451ab (2026-12-02), plus #3113, #3182 and #3204. Diag build. Run A was on a917c54d6, the same
morning, and grew the same way.

System

NVIDIA GeForce RTX 5090 32 GB, driver 621.40; i9-14900KS; 64 GB DDR5; Windows 11 (build 26300). Page file
system-managed.

Where

In the world, from a save, mostly city driving (also on foot). Standing still grows far more slowly.

Command and steps

scripts/play-d3d12.ps1 -HardwareRT -SmoothMotion -PrecompileAll -Log. Series X profile, output 3840x2160,
render scale 0.6667, LEONIDA_REAPER=0, LEONIDA_FPS_CAP=0. Load a save and drive around the city for 10 to 15
minutes, then read the copystat: memory: lines and the census line.

Output

A copystat line from run B at its end:

memory: 43394 MB private (... the PC has ... MB free and 5245 MB left to commit); host copies of title memory: ...;
host textures: 163784 alive 13918 MB ...

Related: #3201 (partial fix: textures freed, blocks kept), #2821 (device removed after 5-46 min on a 4070 SUPER;
may share this cause), #3129 (16 GB memory wall).


AI-assisted: the log analysis and the write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the
runtime's own log lines from the runs above.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:6756538064 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3261). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-12-02T23:12:41Z. --- ### What happens On a high-RAM, high-VRAM machine, the process keeps growing for as long as the player moves through the world: private bytes, Windows commit and card memory. Nothing gives the memory back. In a session of 10 to 15 minutes, commit headroom falls toward zero. From there the runtime limits texture prefetch, stutters get worse, roads show missing textures, and a crash follows if the session goes on. Restarting the game is the only workaround. The numbers below are from the runtime's own `copystat` memory lines and `census` lines, over several runs on 2026-12-02. **Growth over one session** (city driving, hardware RT on): | run | private bytes | commit left (Windows) | host textures alive | card memory in use | |---|---|---|---|---| | A, 12 min | 12 GB → **58 GB** | 59 GB → **12.6 GB** | 214k / 17 GB | 2 GB → **28.5 GB** of 31.4 | | B, 5.5 min | 10.9 GB → **43.4 GB** | 36.9 GB → **5.2 GB** | 164k / 13.9 GB | 1.9 GB → **20.7 GB** | | C, 8 min | → 45 GB | → **1.2 GB** | 167k / 13.6 GB | 22.5 GB | | D, ~8 min | → 52.5 GB | → 13.0 GB | 257k / 17.2 GB | 24.4 GB | That is about **+1 GB of commit a minute while driving**, and it never comes back down. - **Correction (edited):** another game (Black Desert) was running on the same PC during these runs and the ones in the comments below. The private bytes, host textures and card memory in the table are the runtime's own process counters (`GetProcessMemoryInfo`, DXGI `QueryVideoMemoryInfo`), so they do not include it. The **Windows commit headroom** is system-wide, so it is lower than on an otherwise idle PC by what that game held, and the card's budget the runtime saw fell from 31.4 GB to about 24.7 GB as VRAM filled, part of which is that game's share. **Where it sits** (the `census` line at the end of runs B and D): ``` pool.rs blocks of textures 11712 MB in 183 (run D: 14976 MB in 234) pool.rs textures in blocks 10914 MB in 162550 (run D: 14145 MB in 256020) shadow.rs shared buffers in blocks 2524 MB in 631 (run D: 4948 MB in 1237) ``` The 64 MiB `DEFAULT` texture blocks make up the bulk, and they only grow. **What exists today, and why it is not enough here:** - **`LEONIDA_REAPER=1`** (with `LEONIDA_REAPER_LIMIT`): on this machine, commit headroom still fell from 28.9 GB to 6.9 GB in 15 minutes. In earlier builds it crashed after about 8 minutes. Retried tonight on the build below with DLSS on: the device was lost about 50 s into the world (`device removed`, 0x887A0006). The same build and settings without the reaper then ran 8 minutes with no device loss. That is one run each, so not proof. So I run with `LEONIDA_REAPER=0`, and the table above is with it off. - **#3201** (commit-aware texture pool, `LEONIDA_COMMIT_FLOOR` on): I tested it in game (comment there). Once headroom fell to about 4.5 GB, it did let go of idle textures, 184k → 24k. But the **64 MiB blocks stayed**: 192 blocks, 12.3 GB, holding 2.1 GB of live textures. So private bytes, commit and card memory kept their trend. **Suggestion:** give back texture blocks (and shared-buffer blocks) once they are empty or nearly empty, or compact them, driven by the same commit floor. Or cap the pool's block count by the card's budget on cards where VRAM is not the limit but commit is. ### Commit Upstream main `0d7a451ab` (2026-12-02), plus #3113, #3182 and #3204. Diag build. Run A was on `a917c54d6`, the same morning, and grew the same way. ### System NVIDIA GeForce RTX 5090 32 GB, driver 621.40; i9-14900KS; 64 GB DDR5; Windows 11 (build 26300). Page file system-managed. ### Where In the world, from a save, mostly city driving (also on foot). Standing still grows far more slowly. ### Command and steps `scripts/play-d3d12.ps1 -HardwareRT -SmoothMotion -PrecompileAll -Log`. Series X profile, output 3840x2160, render scale 0.6667, `LEONIDA_REAPER=0`, `LEONIDA_FPS_CAP=0`. Load a save and drive around the city for 10 to 15 minutes, then read the `copystat: memory:` lines and the `census` line. ### Output A `copystat` line from run B at its end: ``` memory: 43394 MB private (... the PC has ... MB free and 5245 MB left to commit); host copies of title memory: ...; host textures: 163784 alive 13918 MB ... ``` Related: #3201 (partial fix: textures freed, blocks kept), #2821 (device removed after 5-46 min on a 4070 SUPER; may share this cause), #3129 (16 GB memory wall). --- AI-assisted: the log analysis and the write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines from the runs above.
x2Tweek commented 2026-12-03 06:17:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-03T06:17:23Z.


Scripted repro without driving: camera spinning in place. Memory climbs fast, then plateaus. The reaper changes nothing.

Same machine as in the issue (RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 26300). Build: current play build (main 0d7a451ab + local patches), diag, -HardwareRT -SmoothMotion -PrecompileAll -Dlss quality, 4K output. The character walks forward (W), and the camera turns with the look keys (L for 20 s, then J for 20 s, repeated) through LEONIDA_KEYS_FILE. A driver script reads the log and presses Enter only while the frame has fewer than 3000 draws, so no input reaches the world before it loads. Each run is 600 s in the world.

time in the world committed, LEONIDA_REAPER=1 committed, LEONIDA_REAPER=0 textures (MB), reaper on / off VRAM in use (MB), reaper on / off
world loaded 30.0 GB 38.1 GB (sample 1.5 min in) 5,069 / 10,918 9,299 / 15,520
~3 min 39.3 GB 43.1 GB 11,969 / 14,873 16,527 / 19,751
~6 min 45.6 GB 45.5 GB 16,713 / 16,987 21,762 / 21,710
~10 min 47.3 GB 45.8 GB 16,439 / 15,938 22,764 / 22,186
  • It climbs, then stops. Spinning in place reaches about 46 GB committed, about 16 GB of textures and about 22 GB of VRAM in about 6 minutes, then holds there. The commit headroom drops from about 39 GB to about 4-5 GB. The unbounded growth reported above came while driving into new areas, so it seems tied to new streaming regions rather than to the camera.
  • Correction (edited): another game (Black Desert) was running on the same PC during these runs. The private bytes ("committed"), textures and VRAM in use above are the runtime's own process counters (GetProcessMemoryInfo, DXGI QueryVideoMemoryInfo), so they do not include it. The Windows commit headroom is system-wide, so it is lower than on an otherwise idle PC by what that game held, and the card's budget the runtime saw fell from 31.4 GB to about 24.7 GB as VRAM filled, part of which is that game's share.
  • The reaper does nothing measurable here. The curves with LEONIDA_REAPER=1 and =0 match within noise.
  • No crash in either run: 0 device losses, LEONIDA_D3D12_DRED=1 set.
  • Hardware RT over the same 10 minutes: AS memory grew from about 180 MB to 1.0-1.2 GB, with about 72-78k BLAS built and 11-13k BLAS live at the end.
  • Frame rate: 14.2 fps median (reaper on) and 12.9 fps (reaper off).

The scripts (an adaptive menu/world key driver plus a log parser) are small bash; I can attach them if they help with reproducing.

AI-assisted: the runs, the key driver, the log reading and this write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7369669101 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3261#issuecomment-7369669101). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-12-03T06:17:23Z. --- **Scripted repro without driving: camera spinning in place. Memory climbs fast, then plateaus. The reaper changes nothing.** Same machine as in the issue (RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 26300). Build: current play build (main `0d7a451ab` + local patches), diag, `-HardwareRT -SmoothMotion -PrecompileAll -Dlss quality`, 4K output. The character walks forward (`W`), and the camera turns with the look keys (`L` for 20 s, then `J` for 20 s, repeated) through `LEONIDA_KEYS_FILE`. A driver script reads the log and presses Enter only while the frame has fewer than 3000 draws, so no input reaches the world before it loads. Each run is 600 s in the world. | time in the world | committed, `LEONIDA_REAPER=1` | committed, `LEONIDA_REAPER=0` | textures (MB), reaper on / off | VRAM in use (MB), reaper on / off | |---|---|---|---|---| | world loaded | 30.0 GB | 38.1 GB (sample 1.5 min in) | 5,069 / 10,918 | 9,299 / 15,520 | | ~3 min | 39.3 GB | 43.1 GB | 11,969 / 14,873 | 16,527 / 19,751 | | ~6 min | 45.6 GB | 45.5 GB | 16,713 / 16,987 | 21,762 / 21,710 | | ~10 min | 47.3 GB | 45.8 GB | 16,439 / 15,938 | 22,764 / 22,186 | - **It climbs, then stops.** Spinning in place reaches about 46 GB committed, about 16 GB of textures and about 22 GB of VRAM in about 6 minutes, then holds there. The commit headroom drops from about 39 GB to about 4-5 GB. The unbounded growth reported above came while driving into new areas, so it seems tied to new streaming regions rather than to the camera. - **Correction (edited):** another game (Black Desert) was running on the same PC during these runs. The private bytes ("committed"), textures and VRAM in use above are the runtime's own process counters (`GetProcessMemoryInfo`, DXGI `QueryVideoMemoryInfo`), so they do not include it. The **Windows commit headroom** is system-wide, so it is lower than on an otherwise idle PC by what that game held, and the card's budget the runtime saw fell from 31.4 GB to about 24.7 GB as VRAM filled, part of which is that game's share. - **The reaper does nothing measurable here.** The curves with `LEONIDA_REAPER=1` and `=0` match within noise. - **No crash in either run:** 0 device losses, `LEONIDA_D3D12_DRED=1` set. - **Hardware RT over the same 10 minutes:** AS memory grew from about 180 MB to 1.0-1.2 GB, with about 72-78k BLAS built and 11-13k BLAS live at the end. - **Frame rate:** 14.2 fps median (reaper on) and 12.9 fps (reaper off). The scripts (an adaptive menu/world key driver plus a log parser) are small bash; I can attach them if they help with reproducing. AI-assisted: the runs, the key driver, the log reading and this write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.
merzleckeier commented 2026-12-03 06:21:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T06:21:46Z.


For D3D12-POOL-PACK-FULLEST-BLOCK, I reproduced the re-pin behavior with the exact Pool / Ranges code from d9b618f10, using synthetic block handles and a fixed clock.

Two ripe 64 MiB blocks have 8 MiB and 48 MiB live, with room in both for a new 8 MiB piece. With the sparse block first, the current allocator places the new piece there. When that block’s original piece is returned and finishes resting, the pool still has two blocks even with reclaim(..., 0, true). Reversing only the two block entries sends the new piece to the fuller block. The sparse block then drops from the pool exactly when its original piece finishes resting, leaving one block. There was no GPU allocation in this test.

This gives the packing change a small acceptance case and shows how it complements #3201: a lower empty-spare limit only helps once the sparse block actually becomes empty. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7369749266 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3261#issuecomment-7369749266). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T06:21:46Z. --- For [D3D12-POOL-PACK-FULLEST-BLOCK](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7369548016), I reproduced the re-pin behavior with the exact `Pool` / `Ranges` code from `d9b618f10`, using synthetic block handles and a fixed clock. Two ripe 64 MiB blocks have 8 MiB and 48 MiB live, with room in both for a new 8 MiB piece. With the sparse block first, the current allocator places the new piece there. When that block’s original piece is returned and finishes resting, the pool still has two blocks even with `reclaim(..., 0, true)`. Reversing only the two block entries sends the new piece to the fuller block. The sparse block then drops from the pool exactly when its original piece finishes resting, leaving one block. There was no GPU allocation in this test. This gives the packing change a small acceptance case and shows how it complements #3201: a lower empty-spare limit only helps once the sparse block actually becomes empty. AI-assisted with OpenAI Codex.
timh8127 commented 2026-12-03 13:44:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ubiquitarianism/leonida. Originally posted by timh8127 on 2026-12-03T13:44:02Z.


A 32 GB PC: private bytes level off at about 27–28 GB, but physical memory is under pressure much of the time

Same build and settings as my comment in #3255 (https://github.com/ProjectLeonida/mandy/issues/3255#issuecomment-7380290745): RTX 5070 12 GB, 32 GB RAM + 32 GB fixed page file (commit limit 63.1 GB), Series X, DLSS + FG 2×, LEONIDA_WINDOWS_BAR_MB=3072 (the play script's default under 48 GB of RAM). From the copystat memory lines, the video memory lines and the residency summary (MB from the log ÷ 1024):

private free RAM commit left card memory in use
first minute, loading into the world (both runs) 11.1–24.8 GB 0.4–7.2 GB 16.7–30.2 GB 1.9–8.7 GB
run 1, the rest of ~15 min in the world (a paused stretch left out) 24.3–28.4 GB 0.4–4.7 GB 13.1–17.6 GB 8.5–9.4 GB
run 2, ~6 min (story cutscenes, then the first boat mission, driving the boat) 24.4–27.5 GB 0.5–5.3 GB 13.9–17.1 GB 8.4–9.3 GB
  • Neither run showed a steady climb like the one in the issue: private bytes levelled off at 27–28 GB in run 1 and at 27.5 GB in run 2 (too short to say much).
  • residency: run 1 had 1,962 of 2,034 one-second looks under pressure, run 2 had 265 of 500, every one by physical memory alone (commit never under 4 GiB left). The least seen: 291 MB and 469 MB of physical memory free, with 13,264 and 13,973 MB left to commit. On 32 GB the wall is physical memory, well before commit.
  • An earlier, unlogged run on the same PC (read from the OS counters after 62 minutes) had 28.7 GB private and 13.0 GB commit left.

Numbers collected from the logs with Claude Opus 5.5 (AI-assisted); reviewed by me before posting.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7380296970 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3261#issuecomment-7380296970). Originally posted by [timh8127](https://github.com/timh8127) on 2026-12-03T13:44:02Z. --- **A 32 GB PC: private bytes level off at about 27–28 GB, but physical memory is under pressure much of the time** Same build and settings as my comment in #3255 (https://github.com/ProjectLeonida/mandy/issues/3255#issuecomment-7380290745): RTX 5070 12 GB, 32 GB RAM + 32 GB fixed page file (commit limit 63.1 GB), Series X, DLSS + FG 2×, `LEONIDA_WINDOWS_BAR_MB=3072` (the play script's default under 48 GB of RAM). From the `copystat` memory lines, the video memory lines and the residency summary (MB from the log ÷ 1024): | | private | free RAM | commit left | card memory in use | |---|---|---|---|---| | first minute, loading into the world (both runs) | 11.1–24.8 GB | 0.4–7.2 GB | 16.7–30.2 GB | 1.9–8.7 GB | | run 1, the rest of ~15 min in the world (a paused stretch left out) | 24.3–28.4 GB | 0.4–4.7 GB | 13.1–17.6 GB | 8.5–9.4 GB | | run 2, ~6 min (story cutscenes, then the first boat mission, driving the boat) | 24.4–27.5 GB | 0.5–5.3 GB | 13.9–17.1 GB | 8.4–9.3 GB | - Neither run showed a steady climb like the one in the issue: private bytes levelled off at 27–28 GB in run 1 and at 27.5 GB in run 2 (too short to say much). - `residency`: run 1 had 1,962 of 2,034 one-second looks under pressure, run 2 had 265 of 500, every one by physical memory alone (commit never under 4 GiB left). The least seen: 291 MB and 469 MB of physical memory free, with 13,264 and 13,973 MB left to commit. On 32 GB the wall is physical memory, well before commit. - An earlier, unlogged run on the same PC (read from the OS counters after 62 minutes) had 28.7 GB private and 13.0 GB commit left. _Numbers collected from the logs with Claude Opus 5.5 (AI-assisted); reviewed by me before posting._
Sign in to join this conversation.
No labels
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.

Reference
ProjectLeonida/mandy#3261
No description provided.