d3d12: memory grows without bound while driving on a 64 GB / 32 GB machine; texture-pool blocks are never given back #3261
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
copystatmemory lines andcensuslines, over several runs on2026-12-02.
Growth over one session (city driving, hardware RT on):
That is about +1 GB of commit a minute while driving, and it never comes back down.
GetProcessMemoryInfo, DXGIQueryVideoMemoryInfo), 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
censusline at the end of runs B and D):The 64 MiB
DEFAULTtexture blocks make up the bulk, and they only grow.What exists today, and why it is not enough here:
LEONIDA_REAPER=1(withLEONIDA_REAPER_LIMIT): on this machine, commit headroom still fell from 28.9 GB to6.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 settingswithout 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.LEONIDA_COMMIT_FLOORon): I tested it in game (comment there). Onceheadroom 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 ona917c54d6, the samemorning, 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 15minutes, then read the
copystat: memory:lines and thecensusline.Output
A
copystatline from run B at its end: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.
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 (Lfor 20 s, thenJfor 20 s, repeated) throughLEONIDA_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.LEONIDA_REAPER=1LEONIDA_REAPER=0GetProcessMemoryInfo, DXGIQueryVideoMemoryInfo), 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.LEONIDA_REAPER=1and=0match within noise.LEONIDA_D3D12_DRED=1set.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.
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/Rangescode fromd9b618f10, 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.
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 thecopystatmemory lines, the video memory lines and the residency summary (MB from the log ÷ 1024):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.Numbers collected from the logs with Claude Opus 5.5 (AI-assisted); reviewed by me before posting.