Memory profiling: 5.67 GiB retained by a single shadow.rs allocation call site — RTX 5060 8GB #2024

Closed
opened 2026-11-29 07:48:18 +00:00 by github-bot · 4 comments
Owner

@⁠kartincev057-byte on GitHub · 2026-11-29 07:46 UTC · original

I've been working on an experimental VIctory branch called ARS (Adaptive Resource System), focused on investigating performance, memory management, and resource lifetimes.

Across three development milestones (M1, M2, and M2.1), I implemented additional profiling for system memory, GPU memory, DXGI budgets, allocation ownership, memory pools, deferred resource retirement, and texture streaming.

I'd like to share some hardware profiling results that may contribute to ongoing VIctory optimization efforts.

ARS_M2.1_RTX5060_Profiling_Public.zip

  • GPU: NVIDIA GeForce RTX 5060 8 GB.
  • Driver: 621.1.0.
  • RAM: 32 GB.
  • Windows, build 26300.
  • Series X profile.
  • DLSS Balanced.
  • Frame Generation 2X requested.
  • Warm shader/PSO cache.

Latest tested build:

ARS M2.1 — d2167786f60081908103ad7a4c58f90d5cca3965

1. Comparison across three development milestones

All memory values are in GiB.

Metric M1 M2 M2.1
Session duration 533 s 514 s 570 s
Peak Working Set 23.82 22.37 24.53
Peak Private Bytes 25.15 24.31 26.81
Peak DXGI Local 8.32 7.37 8.60
Peak DXGI Non-local 7.86 7.78 8.39
Minimum Available RAM 0.95 2.97 0.41
Live Upload/Readback 5.83 6.14 6.90
Live Texture allocations 3.99 3.30 4.49
Session frame P95 155 ms 109 ms 175 ms
Approximate gameplay median FPS 8.8 10.65 7.9

The sessions included different gameplay scenes, so these results should not be interpreted as a controlled A/B benchmark.

2. Main finding: shadow.rs

After adding per-call-site allocation ownership telemetry in M2.1, I was able to identify the largest contributor to tracked Upload/Readback memory.

Source: shadow.rs:6173
Backing: committed-shared-L0
Category: upload_readback

Allocated bytes: 11909726208
Freed bytes: 5817499648
Live bytes: 6092226560
Peak bytes: 6165626880

Objects created: 1852
Objects freed: 899
Live objects: 953
Peak objects: 963

Average freed resource age: 16124 ms
Maximum freed resource age: 404677 ms

A single allocation call site retained approximately 5.67 GiB, accounting for approximately 82.3% of all tracked Upload/Readback allocations.

The source line refers to the specific experimental branch commit listed above.

Resources are being released: approximately 5.42 GiB of cumulative allocations were freed throughout the session.

Therefore, the current evidence is insufficient to classify this behavior as a conventional memory leak.

The next step is to determine how much of this memory belongs to the required working set and how much may be retained unnecessarily.

3. Memory growth over time

Selected samples from the largest allocation owner:

Session time Live memory Live objects
391 s 4.93 GiB 829
441 s 5.00 GiB 842
466 s 5.65 GiB 949
491 s 5.71 GiB 958
566 s 5.67 GiB 953

The interval between 441 and 466 seconds is particularly interesting: the number of live objects increased by 107, while retained memory increased by approximately 666 MiB.

Continued RAM and VRAM growth was also observed while the character and camera remained stationary. However, the exact boundaries of the stationary period were not marked in the telemetry.

4. Deferred Resource Retirement

M2 introduced an experimental mechanism for coalescing duplicate retirement references.

Metric M1 M2 M2.1
Peak queue entries 417092 23725 25611
Final queue entries 144809 1792 11795

The peak retirement queue entry count decreased by approximately 94.3% between M1 and M2.

This does not imply an equivalent reduction in unique resources or physical memory usage.

Further validation of COM ownership, resource generations, and GPU fence dependencies is required.

5. Texture streaming and the memory/correctness trade-off

M2 exhibited significant texture queue accumulation:

  • Due texture slots: 22372.
  • Oldest pending upload: 4840 frames.
  • Black building materials.
  • Green and magenta texture artifacts.
  • Water rendering artifacts.

M2.1 modified texture queue admission and processing policies.

The final CSV sample reported zero due slots. However, the last corresponding line in the main log before shutdown still reported 348 due slots. Complete elimination of texture starvation has not been established.

Visual material loading improved substantially, but tracked texture allocations increased from 3.30 to 4.49 GiB.

This suggests a potential trade-off between limiting memory consumption and preserving rendering correctness.

6. DLSS and Frame Generation

After integrating changes related to #856:

  • Successful SR evaluations without warnings: 3.
  • Successful SR evaluations with budget warning: 3672.
  • Actual SR evaluation errors: 0.
  • FG GetState budget warnings: 54.

DLSS Frame Generation 2X activated successfully but was disabled approximately nine seconds later.

Correct handling of Streamline status 39 allowed budget warnings to be distinguished from actual DLSS evaluation failures.

However, GPU memory pressure remains unresolved.

7. Ineffective idle buffer trimming

Another finding from M2.1:

send_idle_bytes = 419430400
send_trim_attempts = 271
send_trim_bytes = 0
card_readback_trim_bytes = 0
relay_readback_trim_bytes = 0

Despite 271 recorded send-buffer trim attempts, the mechanism recorded no reclaimed memory.

Reclamation eligibility, minimum pool reserves, last-use timestamps, and fence completion conditions require further investigation.

8. Potential investigation targets

  • Lifetime of committed-shared-L0 allocations in shadow.rs.
  • Potential duplicate backing allocations.
  • Fence-aware resource reuse.
  • Safe reclamation of unused shadow resources.
  • Potential use of placed resources instead of some committed allocations.
  • Reduction of unnecessary CPU/GPU copies.
  • Memory budget recovery after transient operations complete.
  • Preservation of mandatory texture streaming under memory pressure.

Conclusion

I'm continuing this investigation in ARS M2.2.

I'm not claiming to have established a memory leak or resolved the issues described above. The purpose of this report is to share concrete hardware measurements and help identify potential optimization targets.

Has anyone previously investigated the lifetime of committed-shared-L0 allocations in shadow.rs, or ways to reduce this working set without compromising CPU/GPU coherency?

I'd be happy to share sanitized CSV files, detailed logs, the profiling implementation, and further experimental results.

Development was AI-assisted using OpenAI Codex. All reported hardware measurements were collected during actual execution on my own PC.

Thanks to everyone contributing to VIctory!

**@⁠kartincev057-byte** on GitHub · 2026-11-29 07:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2024) I've been working on an experimental VIctory branch called ARS (Adaptive Resource System), focused on investigating performance, memory management, and resource lifetimes. Across three development milestones (M1, M2, and M2.1), I implemented additional profiling for system memory, GPU memory, DXGI budgets, allocation ownership, memory pools, deferred resource retirement, and texture streaming. I'd like to share some hardware profiling results that may contribute to ongoing VIctory optimization efforts. ## [ARS_M2.1_RTX5060_Profiling_Public.zip](https://github.com/user-attachments/files/35565949/ARS_M2.1_RTX5060_Profiling_Public.zip) - GPU: NVIDIA GeForce RTX 5060 8 GB. - Driver: 621.1.0. - RAM: 32 GB. - Windows, build 26300. - Series X profile. - DLSS Balanced. - Frame Generation 2X requested. - Warm shader/PSO cache. Latest tested build: `ARS M2.1 — d2167786f60081908103ad7a4c58f90d5cca3965` ## 1. Comparison across three development milestones All memory values are in GiB. | Metric | M1 | M2 | M2.1 | |---|---:|---:|---:| | Session duration | 533 s | 514 s | 570 s | | Peak Working Set | 23.82 | 22.37 | 24.53 | | Peak Private Bytes | 25.15 | 24.31 | 26.81 | | Peak DXGI Local | 8.32 | 7.37 | 8.60 | | Peak DXGI Non-local | 7.86 | 7.78 | 8.39 | | Minimum Available RAM | 0.95 | 2.97 | 0.41 | | Live Upload/Readback | 5.83 | 6.14 | 6.90 | | Live Texture allocations | 3.99 | 3.30 | 4.49 | | Session frame P95 | 155 ms | 109 ms | 175 ms | | Approximate gameplay median FPS | 8.8 | 10.65 | 7.9 | The sessions included different gameplay scenes, so these results should not be interpreted as a controlled A/B benchmark. ## 2. Main finding: shadow.rs After adding per-call-site allocation ownership telemetry in M2.1, I was able to identify the largest contributor to tracked Upload/Readback memory. ```text Source: shadow.rs:6173 Backing: committed-shared-L0 Category: upload_readback Allocated bytes: 11909726208 Freed bytes: 5817499648 Live bytes: 6092226560 Peak bytes: 6165626880 Objects created: 1852 Objects freed: 899 Live objects: 953 Peak objects: 963 Average freed resource age: 16124 ms Maximum freed resource age: 404677 ms ``` A single allocation call site retained approximately **5.67 GiB**, accounting for approximately **82.3% of all tracked Upload/Readback allocations**. The source line refers to the specific experimental branch commit listed above. Resources are being released: approximately 5.42 GiB of cumulative allocations were freed throughout the session. Therefore, the current evidence is insufficient to classify this behavior as a conventional memory leak. The next step is to determine how much of this memory belongs to the required working set and how much may be retained unnecessarily. ## 3. Memory growth over time Selected samples from the largest allocation owner: | Session time | Live memory | Live objects | |---|---:|---:| | 391 s | 4.93 GiB | 829 | | 441 s | 5.00 GiB | 842 | | 466 s | 5.65 GiB | 949 | | 491 s | 5.71 GiB | 958 | | 566 s | 5.67 GiB | 953 | The interval between 441 and 466 seconds is particularly interesting: the number of live objects increased by 107, while retained memory increased by approximately 666 MiB. Continued RAM and VRAM growth was also observed while the character and camera remained stationary. However, the exact boundaries of the stationary period were not marked in the telemetry. ## 4. Deferred Resource Retirement M2 introduced an experimental mechanism for coalescing duplicate retirement references. | Metric | M1 | M2 | M2.1 | |---|---:|---:|---:| | Peak queue entries | 417092 | 23725 | 25611 | | Final queue entries | 144809 | 1792 | 11795 | The peak retirement queue entry count decreased by approximately 94.3% between M1 and M2. This does not imply an equivalent reduction in unique resources or physical memory usage. Further validation of COM ownership, resource generations, and GPU fence dependencies is required. ## 5. Texture streaming and the memory/correctness trade-off M2 exhibited significant texture queue accumulation: - Due texture slots: 22372. - Oldest pending upload: 4840 frames. - Black building materials. - Green and magenta texture artifacts. - Water rendering artifacts. M2.1 modified texture queue admission and processing policies. The final CSV sample reported zero due slots. However, the last corresponding line in the main log before shutdown still reported 348 due slots. Complete elimination of texture starvation has not been established. Visual material loading improved substantially, but tracked texture allocations increased from 3.30 to 4.49 GiB. This suggests a potential trade-off between limiting memory consumption and preserving rendering correctness. ## 6. DLSS and Frame Generation After integrating changes related to #856: - Successful SR evaluations without warnings: 3. - Successful SR evaluations with budget warning: 3672. - Actual SR evaluation errors: 0. - FG GetState budget warnings: 54. DLSS Frame Generation 2X activated successfully but was disabled approximately nine seconds later. Correct handling of Streamline status 39 allowed budget warnings to be distinguished from actual DLSS evaluation failures. However, GPU memory pressure remains unresolved. ## 7. Ineffective idle buffer trimming Another finding from M2.1: ```text send_idle_bytes = 419430400 send_trim_attempts = 271 send_trim_bytes = 0 card_readback_trim_bytes = 0 relay_readback_trim_bytes = 0 ``` Despite 271 recorded send-buffer trim attempts, the mechanism recorded no reclaimed memory. Reclamation eligibility, minimum pool reserves, last-use timestamps, and fence completion conditions require further investigation. ## 8. Potential investigation targets - Lifetime of committed-shared-L0 allocations in shadow.rs. - Potential duplicate backing allocations. - Fence-aware resource reuse. - Safe reclamation of unused shadow resources. - Potential use of placed resources instead of some committed allocations. - Reduction of unnecessary CPU/GPU copies. - Memory budget recovery after transient operations complete. - Preservation of mandatory texture streaming under memory pressure. ## Conclusion I'm continuing this investigation in ARS M2.2. I'm not claiming to have established a memory leak or resolved the issues described above. The purpose of this report is to share concrete hardware measurements and help identify potential optimization targets. **Has anyone previously investigated the lifetime of committed-shared-L0 allocations in shadow.rs, or ways to reduce this working set without compromising CPU/GPU coherency?** I'd be happy to share sanitized CSV files, detailed logs, the profiling implementation, and further experimental results. Development was AI-assisted using OpenAI Codex. All reported hardware measurements were collected during actual execution on my own PC. Thanks to everyone contributing to VIctory!
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 07:48:19 +00:00
Author
Owner

@⁠ArturoWolff on GitHub · 2026-11-29 07:58 UTC · original

Thanks for the careful distinction between live allocations, cumulative frees and a proven leak. The closely related existing work is #1823, which changes eligible persistent CPU-only buffer mirrors from shared D3D12 memory to ordinary pageable process memory while retaining GPU readback/copy correctness checks.

Our independent Linux/Proton RTX 4060 8 GB / 16 GB RAM validation and startup follow-up supports the DXGI nonlocal accounting change on synthetic data. It did not establish a physical host-RAM saving or a gameplay improvement; the actual startup comparison was interrupted on the control arm, and observed private mirrors were only 174 MiB at that earlier workload milestone. Those bytes are not comparable to your later gameplay allocation-owner census.

Your 5.67 GiB attributed live set is useful motivation for comparing the eligible mirror bytes, actual shared allocation lifetime and fence retirement with matched scene/progress and the same source revision. I would keep unique underlying allocations, reference counts, residency and cumulative allocations separate. I do not have evidence that all of the reported live memory is redundant or that moving it into pageable memory alone resolves the working-set problem.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).

**@⁠ArturoWolff** on GitHub · 2026-11-29 07:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2024#issuecomment-7252803620) Thanks for the careful distinction between live allocations, cumulative frees and a proven leak. The closely related existing work is [#1823](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/1823), which changes eligible persistent CPU-only buffer mirrors from shared D3D12 memory to ordinary pageable process memory while retaining GPU readback/copy correctness checks. Our independent [Linux/Proton RTX 4060 8 GB / 16 GB RAM validation and startup follow-up](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/1823) supports the DXGI nonlocal accounting change on synthetic data. It did not establish a physical host-RAM saving or a gameplay improvement; the actual startup comparison was interrupted on the control arm, and observed private mirrors were only 174 MiB at that earlier workload milestone. Those bytes are not comparable to your later gameplay allocation-owner census. Your 5.67 GiB attributed live set is useful motivation for comparing the eligible mirror bytes, actual shared allocation lifetime and fence retirement with matched scene/progress and the same source revision. I would keep unique underlying allocations, reference counts, residency and cumulative allocations separate. I do not have evidence that all of the reported live memory is redundant or that moving it into pageable memory alone resolves the working-set problem. AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).
Author
Owner

@⁠kartincev057-byte on GitHub · 2026-11-29 08:03 UTC · original

@⁠ArturoWolff Thanks for the detailed response and the reference to #1823!

Interestingly, our ongoing M2.2 investigation has identified a potential source of excessive memory allocation within shadow::loose. Root CBV accesses that update at most 64 KiB could previously trigger the creation of a 6 MiB backing window.

We've implemented a conservative optimization for unaligned CBVs. Shorter windows for aligned CBVs and fence-aware L0 buffer reuse remain experimental due to potential CPU/GPU coherency risks.

M2.2 has just been built, and hardware validation on my RTX 5060 8 GB is starting now.

I'll definitely investigate #1823 and its compatibility with ARS. I agree that reducing DXGI nonlocal usage does not necessarily translate into physical RAM savings.

Thank you for sharing your research. I'll post the new hardware measurements once testing is complete!

**@⁠kartincev057-byte** on GitHub · 2026-11-29 08:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2024#issuecomment-7252853094) @⁠ArturoWolff Thanks for the detailed response and the reference to #1823! Interestingly, our ongoing M2.2 investigation has identified a potential source of excessive memory allocation within `shadow::loose`. Root CBV accesses that update at most 64 KiB could previously trigger the creation of a 6 MiB backing window. We've implemented a conservative optimization for unaligned CBVs. Shorter windows for aligned CBVs and fence-aware L0 buffer reuse remain experimental due to potential CPU/GPU coherency risks. M2.2 has just been built, and hardware validation on my RTX 5060 8 GB is starting now. I'll definitely investigate #1823 and its compatibility with ARS. I agree that reducing DXGI nonlocal usage does not necessarily translate into physical RAM savings. Thank you for sharing your research. I'll post the new hardware measurements once testing is complete!
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-29 08:56 UTC · original

Opened PR #2063 targeting the loose root CBV allocation path in crates/victory-gpu/src/draw.rs + crates/victory-gpu/src/shadow.rs:

  • Unaligned loose root CBVs previously fell through shadow::find(address, 0), allocating and pinning 6 MiB shadow::LOOSE buffers that place_constant could never bind (forcing scratch copy anyway). They now route directly to scratch via shadow::find_root_cbv without touching shadow::LOOSE.
  • Aligned loose root CBVs now ask shadow::loose(..., /* unsized_ask = */ false, false) for a sized 64 KiB (ROOT_CBV_LEN) range instead of unsized_ask = true, avoiding 6 MiB grow_reach / fine-grid expansion and unsized_asks inflation.
  • < 64 KiB registered buffers and unaligned offsets into registered buffers continue hitting BUFFERS first and clamping to shadow.left(address).
**@⁠steven-seagull27** on GitHub · 2026-11-29 08:56 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2024#issuecomment-7253428077) Opened PR #2063 targeting the loose root CBV allocation path in `crates/victory-gpu/src/draw.rs` + `crates/victory-gpu/src/shadow.rs`: - Unaligned loose root CBVs previously fell through `shadow::find(address, 0)`, allocating and pinning 6 MiB `shadow::LOOSE` buffers that `place_constant` could never bind (forcing scratch copy anyway). They now route directly to scratch via `shadow::find_root_cbv` without touching `shadow::LOOSE`. - Aligned loose root CBVs now ask `shadow::loose(..., /* unsized_ask = */ false, false)` for a sized 64 KiB (`ROOT_CBV_LEN`) range instead of `unsized_ask = true`, avoiding 6 MiB `grow_reach` / fine-grid expansion and `unsized_asks` inflation. - `< 64 KiB` registered buffers and unaligned offsets into registered buffers continue hitting `BUFFERS` first and clamping to `shadow.left(address)`.
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-30 15:37 UTC · original

Closing this because it was opened before v2026.11.29.01, and a great deal has changed since then. The latest release is v2026.11.30.01.

If this still happens, or still applies, on the latest release, please open a new issue. For a bug, attach both logs from that run:

  1. The play log: the newest victory-nvidia-play-<date>-<time>-<number>.log in %LOCALAPPDATA%\victory\logs\.
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, plus the newest .crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\ if there is one from that run.
**@⁠trustno1-coder** on GitHub · 2026-11-30 15:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2024#issuecomment-7283308432) Closing this because it was opened before v2026.11.29.01, and a great deal has changed since then. The latest release is [v2026.11.30.01](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/tag/v2026.11.30.01). If this still happens, or still applies, on the latest release, please open a new issue. For a bug, attach both logs from that run: 1. The play log: the newest `victory-nvidia-play-<date>-<time>-<number>.log` in `%LOCALAPPDATA%\victory\logs\`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, plus the newest `.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\` if there is one from that run.
This discussion has been locked. Commenting is limited to contributors.
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#2024
No description provided.