GPU/VRAM: investigate resource retention by released dynamic descriptor slots under memory pressure #266
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#266
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?
@FunWithFlagsDev on GitHub · 2026-11-26 13:50 UTC · original
<html>Summary
While investigating memory pressure on NVIDIA GPUs with 8 GiB of VRAM, I identified a potentially important distinction between dynamic descriptor slot reclamation and the reclamation of resources referenced by those slots.
HostHeap::release()returns descriptor indices to the allocator but does not clear the corresponding retainedID3D12Resourcereferences.Consequently, a dynamic descriptor slot can be available for allocation while still retaining its previous buffer or texture.
This may also interfere with idle texture reclamation, which explicitly requires the host texture to have a single remaining COM reference.
However, some of this retention is intentional and protects against previously observed GPU page faults. This report therefore proposes measurement and controlled validation rather than unconditional resource release.
1. Affected revision
Repository:
avatarmanz/VIctory-7900XTXCommit:
c9c932cbcc38defd8f1683d62dd298187f565031Relevant files:
crates/victory-gpu/src/descriptor/host.rscrates/victory-gpu/src/descriptor.rscrates/victory-gpu/src/draw.rscrates/victory-gpu/src/resource.rscrates/victory-gpu/src/host.rscrates/victory-gpu/src/pool.rs2. Descriptor allocation state and resource ownership are independent
The dynamic descriptor release implementation is located in:
descriptor/host.rs:2780–2793This releases the allocator reservation.
However, it does not:
Remove the retained resource from
self.kept.Replace the existing descriptor with a null descriptor.
Clear an associated raw twin.
Transfer the retained resource to the retirement mechanism.
The allocator's free-slot state is therefore independent of the resource ownership state.
3. Strong resource references survive slot release
The dynamic raw buffer descriptor path retains its underlying resource:
descriptor/host.rs:2936–2962Similarly,
make_at()andmake_listed()retain resources associated with dynamic descriptors.See:
descriptor/host.rs:2800–2852The
keep()implementation replaces the resource associated with a slot and retires the previous reference:descriptor/host.rs:2908–2931Since
release()does not call this mechanism, a free dynamic slot may retain its previous resource until the slot is overwritten, explicitly cleared or the descriptor heap is destroyed.This is bounded retention rather than evidence of an unbounded memory leak.
4. Potential interaction with idle texture reclamation
The existing idle texture sweep evaluates resource ownership before reclaiming a texture.
See:
resource.rs:2145–2160The relevant conditions include:
Consider a synthetic ownership sequence:
This is a conditional consequence of the current ownership mechanism.
Other references may also prevent reclamation, including:
Active command lists.
Title descriptor slots.
Thread-local descriptor caches.
Pending resource retirements.
Other host-side owners.
The important unresolved question is how often released dynamic slots are the remaining obstacle to texture reclamation.
5. Existing safety rationale must be preserved
The constant-buffer descriptor implementation documents why additional resource retention was introduced:
descriptor/host.rs:3045–3054The comments describe previously observed device page faults when shaders calculated incorrect descriptor indices and accessed memory associated with freed scratch buffers.
The additional slot ownership was introduced as a defensive lifetime mechanism.
Therefore, I am not proposing:
Disabling
VICTORY_SLOT_HOLDSby default.Immediately dropping every resource when a dynamic slot is returned.
Removing the existing retirement delay.
Assuming that GPU fence completion alone guarantees that no future access is possible.
Any optimization must preserve the documented page-fault protection or establish that it is unnecessary for the affected resource category.
The command-list state also documents potential descriptor reuse hazards when a list is submitted again after its tables have been returned.
See:
draw.rs:446–479These considerations should be treated as explicit constraints.
6. Proposed diagnostic instrumentation
Before modifying resource lifetimes, I suggest measuring the following counters.
Dynamic descriptor ownership
Resource categories
Where identifiable, separate:
Idle texture reclamation
Additional counters could distinguish:
The final counter requires establishing that free dynamic descriptor ownership is the relevant remaining obstacle, rather than simply finding another reference to the same resource.
Memory accounting
Resource counts must be deduplicated by COM identity.
Multiple descriptors referencing the same resource should not be interpreted as multiple independent memory allocations.
For placed textures and suballocated scratch buffers, backing allocations must be considered separately.
Estimated resource sizes should not be presented as measured physical VRAM residency.
Where possible, correlate the diagnostic counters with DXGI local and nonlocal memory usage.
Diagnostics should avoid retaining additional resource references that could themselves interfere with the reference-count-based idle reclamation test.
Sampling should occur outside the hot draw path.
7. Asset-free synthetic validation
The attached Python model verifies basic resource ownership and concurrent slot-reuse invariants.
All eight tests passed.
The model covers:
Current release retaining resource ownership.
Resource replacement after slot reuse.
Shared references to a single resource.
Deduplication by resource identity.
Cleanup ordering.
Protection of a subsequent slot owner.
Empty allocator state.
Exhaustive enumeration of three legal abstract cleanup orderings.
Illustrative synthetic ownership results:
These implementations continue returning allocator ranges without clearing the corresponding retained resources in
release().This is complementary to their objectives.
In particular:
#47 improves free-range allocation.
#48 returns descriptor ranges earlier after GPU completion.
#96 introduces sharded descriptor allocation.
#237 improves NVIDIA descriptor allocation and early release.
#212 introduces fence-safe texture eviction and adaptive mip clamping.
Earlier descriptor index reclamation does not necessarily imply earlier reclamation of the resources referenced by those descriptors.
The diagnostic work may also complement #69, which introduces memory-category logging.
The duplicate search was limited to selected PRs and source paths.
11. Possible optimization after validation
If diagnostics establish meaningful memory pressure from released dynamic slots, a narrowly scoped opt-in optimization could be investigated.
Potential requirements include:
Confirmed GPU completion.
Explicit handling of device removal.
No possible subsequent command-list replay using the released descriptor.
Preservation of defensive ownership for invalid shader indexing.
Replacement of old descriptors and raw twins before retirement.
Atomic ownership transfer relative to allocator reuse.
Existing deferred resource retirement and bury-lag semantics.
No interference with newer slot generations.
No additional lock-ordering hazards.
The existing resource retirement implementation should be preserved:
host.rs:591–625A blanket removal of retained references is not recommended.
12. Relevance to NVIDIA GPUs with limited VRAM
This investigation complements two earlier reports:
#256 — Recovery after transient texture allocation failures.
#262 — Texture pool accounting and allocation eligibility.
The three investigations address different stages of memory management:
The objective is to determine whether a meaningful amount of memory can be reclaimed safely without weakening existing stability protections.
Attachment
avatar_descriptor_retention_audit.zipContents:
README.mdmodel.pytest_model.pyresults.txtnative_probe.rsReproduction:
No external Python dependencies are required.
Requested verification
Could an independent contributor run the proposed native observation test and determine whether free dynamic descriptor references are a significant obstacle to idle texture reclamation?
If the retained resources account for meaningful memory pressure, I suggest coordinating a diagnostic-first optimization with the authors of #48, #69, #212 and #237.
Credits and limitations
AI-assisted source investigation, synthetic ownership modeling and test design using ChatGPT.
Only public repository source and invented test data were used. No proprietary game files, binaries, SDK material, shader dumps or gameplay captures are included.
All eight Python tests passed.
The proposed Rust observation test has not been compiled or executed by this investigation.
No production correction, native concurrency reproduction, measured VRAM reduction or FPS improvement is claimed.
</html>## SummaryWhile investigating memory pressure on NVIDIA GPUs with 8 GiB of VRAM, I identified a potentially important distinction between dynamic descriptor slot reclamation and the reclamation of resources referenced by those slots.
HostHeap::release()returns descriptor indices to the allocator but does not clear the corresponding retainedID3D12Resourcereferences.Consequently, a dynamic descriptor slot can be available for allocation while still retaining its previous buffer or texture.
This may also interfere with idle texture reclamation, which explicitly requires the host texture to have a single remaining COM reference.
However, some of this retention is intentional and protects against previously observed GPU page faults. This report therefore proposes measurement and controlled validation rather than unconditional resource release.
1. Affected revision
Repository:
avatarmanz/VIctory-7900XTXCommit:
c9c932cbcc38defd8f1683d62dd298187f565031Relevant files:
crates/victory-gpu/src/descriptor/host.rscrates/victory-gpu/src/descriptor.rscrates/victory-gpu/src/draw.rscrates/victory-gpu/src/resource.rscrates/victory-gpu/src/host.rscrates/victory-gpu/src/pool.rs2. Descriptor allocation state and resource ownership are independent
The dynamic descriptor release implementation is located in:
[descriptor/host.rs:2780–2793](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2780-L2793)This releases the allocator reservation.
However, it does not:
self.kept.The allocator's free-slot state is therefore independent of the resource ownership state.
3. Strong resource references survive slot release
The dynamic raw buffer descriptor path retains its underlying resource:
[descriptor/host.rs:2936–2962](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2936-L2962)Similarly,
make_at()andmake_listed()retain resources associated with dynamic descriptors.See:
[descriptor/host.rs:2800–2852](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2800-L2852)The
keep()implementation replaces the resource associated with a slot and retires the previous reference:[descriptor/host.rs:2908–2931](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2908-L2931)Since
release()does not call this mechanism, a free dynamic slot may retain its previous resource until the slot is overwritten, explicitly cleared or the descriptor heap is destroyed.This is bounded retention rather than evidence of an unbounded memory leak.
4. Potential interaction with idle texture reclamation
The existing idle texture sweep evaluates resource ownership before reclaiming a texture.
See:
[resource.rs:2145–2160](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/resource.rs#L2145-L2160)The relevant conditions include:
Consider a synthetic ownership sequence:
This is a conditional consequence of the current ownership mechanism.
Other references may also prevent reclamation, including:
The important unresolved question is how often released dynamic slots are the remaining obstacle to texture reclamation.
5. Existing safety rationale must be preserved
The constant-buffer descriptor implementation documents why additional resource retention was introduced:
[descriptor/host.rs:3045–3054](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L3045-L3054)The comments describe previously observed device page faults when shaders calculated incorrect descriptor indices and accessed memory associated with freed scratch buffers.
The additional slot ownership was introduced as a defensive lifetime mechanism.
Therefore, I am not proposing:
VICTORY_SLOT_HOLDSby default.Any optimization must preserve the documented page-fault protection or establish that it is unnecessary for the affected resource category.
The command-list state also documents potential descriptor reuse hazards when a list is submitted again after its tables have been returned.
See:
[draw.rs:446–479](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/draw.rs#L446-L479)These considerations should be treated as explicit constraints.
6. Proposed diagnostic instrumentation
Before modifying resource lifetimes, I suggest measuring the following counters.
Dynamic descriptor ownership
Resource categories
Where identifiable, separate:
Idle texture reclamation
Additional counters could distinguish:
The final counter requires establishing that free dynamic descriptor ownership is the relevant remaining obstacle, rather than simply finding another reference to the same resource.
Memory accounting
Resource counts must be deduplicated by COM identity.
Multiple descriptors referencing the same resource should not be interpreted as multiple independent memory allocations.
For placed textures and suballocated scratch buffers, backing allocations must be considered separately.
Estimated resource sizes should not be presented as measured physical VRAM residency.
Where possible, correlate the diagnostic counters with DXGI local and nonlocal memory usage.
Diagnostics should avoid retaining additional resource references that could themselves interfere with the reference-count-based idle reclamation test.
Sampling should occur outside the hot draw path.
7. Asset-free synthetic validation
The attached Python model verifies basic resource ownership and concurrent slot-reuse invariants.
All eight tests passed.
The model covers:
Illustrative synthetic ownership results:
These values are invented test data.
They do not represent observed allocations, physical GPU residency or expected memory savings.
8. Concurrency hazard in a naive correction
Simply clearing a retained reference after making a slot available introduces a potential ownership race.
The final cleanup can remove the new owner's reference.
The synthetic model evaluates the following legal abstract sequences:
This is a potential regression of an incorrectly implemented future correction, not a race demonstrated in the current source.
A candidate implementation would require existing allocator synchronization or a generation-aware quarantined state.
The slot must not become reusable before its required cleanup is complete.
Additional lock-ordering and GPU lifetime constraints must also be considered.
9. Proposed native observation test
The attached
native_probe.rscontains a proposed test for the existingdescriptor/host.rstest module.Test name:
observe_dynamic_slot_resource_retention_after_releaseThe test uses the same synthetic buffer and descriptor APIs as the existing
views_are_made_beside_the_heap_and_copied_intest.Its sequence is:
kept_in()retains the buffer.Suggested execution after reviewing and inserting the proposed test into the pinned source:
The proposed test requires a functioning D3D12 host and deliberately avoids silently passing when no host is available.
It submits no GPU work.
Its purpose is to document baseline resource retention, not to demonstrate that removing the retention would be safe.
A subsequent regression should exercise an actual idle texture with controlled ownership and verify reclamation eligibility.
10. Relationship to existing descriptor and memory PRs
I inspected the
HostHeap::release()implementations in the following candidate revisions:025eddeadff7b61ee48ca039f95161809d015992dca516de780ff3ebfa8d7a65600118787ab3437bdefe56b5a0543d25f8ff9d12e988eb0feaee5e3a77e4543121a687aa17d30347f9ed161bb327c8181e710c4bbeb03ce24bd3f2398621c0cb1c572702These implementations continue returning allocator ranges without clearing the corresponding retained resources in
release().This is complementary to their objectives.
In particular:
Earlier descriptor index reclamation does not necessarily imply earlier reclamation of the resources referenced by those descriptors.
The diagnostic work may also complement #69, which introduces memory-category logging.
The duplicate search was limited to selected PRs and source paths.
11. Possible optimization after validation
If diagnostics establish meaningful memory pressure from released dynamic slots, a narrowly scoped opt-in optimization could be investigated.
Potential requirements include:
The existing resource retirement implementation should be preserved:
[host.rs:591–625](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/host.rs#L591-L625)A blanket removal of retained references is not recommended.
12. Relevance to NVIDIA GPUs with limited VRAM
This investigation complements two earlier reports:
The three investigations address different stages of memory management:
The objective is to determine whether a meaningful amount of memory can be reclaimed safely without weakening existing stability protections.
Attachment
avatar_descriptor_retention_audit.zipContents:
README.mdmodel.pytest_model.pyresults.txtnative_probe.rsReproduction:
No external Python dependencies are required.
Requested verification
Could an independent contributor run the proposed native observation test and determine whether free dynamic descriptor references are a significant obstacle to idle texture reclamation?
If the retained resources account for meaningful memory pressure, I suggest coordinating a diagnostic-first optimization with the authors of #48, #69, #212 and #237.
Credits and limitations
avatar_descriptor_retention_audit.zip
Only public repository source and invented test data were used. No proprietary game files, binaries, SDK material, shader dumps or gameplay captures are included.
All eight Python tests passed.
The proposed Rust observation test has not been compiled or executed by this investigation.
No production correction, native concurrency reproduction, measured VRAM reduction or FPS improvement is claimed.
@LucaruluDev on GitHub · 2026-11-27 12:19 UTC · original
I ran an independent standalone D3D12 harness using synthetic buffers and the debug layer on both WARP and a physical RTX 5070 (driver 621.24).
Results per adapter:
The same SRV slot could be returned and reserved again while an explicit COM reference kept the previous buffer alive. A private-data destruction marker confirmed that the resource was destroyed only after its last owner released it, including the extra-owner and deferred-retirement controls.
This validates the resource ownership mechanism in a synthetic single-slot model. The behavior of
HostHeap::releaseitself was checked through source review.Production allocator behavior, idle-texture reclamation rates, and actual VRAM savings remain unmeasured.
I have the standalone C++ source, reproduction script, and traces from both adapters ready to share if useful.