Skip to content

D3D12.X: resources made by resource_at for views of memory (#70/#71) stay cached forever when superseded, memory grows ~8 MB/s in a retail world #2869

Not planned

Description

@Natakout

Placed textures superseded at the same address are never released by a retail title, about 140 per second in its world, and each one costs about 58 KB of commit and 28 KB of local video memory. Over 20 minutes the frame rate falls from 3 to 0.25 presents/s.

RTX 3060 12 GB (NVIDIA 621.14), i9-13900K, 64 GB, Windows 11 26200. Tree: main b49be18 + #2404 + #2590 + #2301 + #751, direct DXIL, XCL_DEVICE_TYPE=lockhart, recipe from #505. Numbers come from local counters (not for upstream) in vram.rs, real.rs (res_release), title_textures.rs and list_x.rs.

The growth. In a 30-minute run in the world, the frame rate fell over 5-minute windows after #101: 3.08, 2.40, 1.91, then 0.25 presents/s. XCL hung at about 1236 s. Between 362 s and 1202 s, the process commit went from 28.4 to 36.1 GB and local video memory from 13.6 to 16.7 GB, steadily, while target pages, the arenas and the sparse pools stayed flat.

Where it goes (16-minute run): vram::PLACED_TEXTURES keeps growing, while title_textures stays flat at about 22,000 entries.

  • 172,086 placed textures were made, and only 7,914 got their final release.
  • There were 138,126 unmap_superseded calls, and 136,113 unmapped page targets are still alive.
  • in a 12-minute run, remap_if_unmapped remapped an old texture 128 times, against 74,079 supersedes.
  • The tiles are unmapped. Each old texture is left as an empty reserved resource. Commit and video memory grow by about 58 KB and 28 KB per such resource.

Not a reference held by XCL. Classified by return address in res_release, over 8 minutes: 143,968 releases on placed textures, of which 1,533 come from the title, and 1,526 of these are final. The rest are XCL's own clones being dropped. So the title recreates textures over the same address without ever releasing the old object. On the console the object is probably cheap, perhaps living in title memory, so this is harmless there.

Does the title still use the old object? Over 8 minutes and 40,172 supersedes:

  • GetGPUVirtualAddress is called on an old object 326 times, all from the title;
  • CreateShaderResourceView on an old object: 2,176 calls, none from the title;
  • ResourceBarrier transitions on an old object: 0. Map: 0.

What a fix could reuse:

  • the new texture has the same PC resource desc as the old one at the same address in 17 % of supersedes;
  • a superseded object with the same desc is free somewhere (a desc-indexed pool) in 51 % of creations.

A same-address, same-desc reuse is safe, since the title's GetGPUVirtualAddress gets the same address, but it only removes 17 % of the growth. A pool would remove about half, but the title still calls GetGPUVirtualAddress on old objects, and with a pool those would answer with an unrelated address. Releasing the old object at supersede is not possible either: the title holds the real ID3D12Resource, without a wrapper, and sometimes does release it. I have not found a clean fix. A wrapper for title placed textures looks like the real one.

Related: #1897, #2270 (timing of unmap_superseded, not this growth), #505.

AI use: Claude (claude-opus-5-5, through Hermes) wrote the counters, ran the runs over SSH, worked the numbers out with Thibaut's bot and wrote this.

Activity

  1. Natakout commented on Nov 26, 2026

    @Natakout
    Author

    Follow-up: the title's GetGPUVirtualAddress on superseded objects comes long after the supersede, so a quarantine before pooling would not make a pool safe.

    One 8-minute run, 45,443 supersedes, 371 GetGPUVirtualAddress calls from the title on objects already superseded. Delay from the supersede to each call:

    • under 0.1 s: 4;
    • 0.1 to 0.5 s: 7;
    • 0.5 to 2 s: 3;
    • 2 to 10 s: 22;
    • 10 to 60 s: 127;
    • over 60 s: 208.

    Most calls come more than 10 s after the supersede, so a quarantine of a few frames before an old object can be reused would not cover them. In the same run, a superseded object with the same PC desc was free for 41,687 of 76,519 creations (54 %), and the old entry at the same address had the same desc in 7,994 of 45,407 supersedes (18 %).

  2. upipibi commented on Nov 26, 2026

    @upipibi
    Contributor

    Not every superseded placed texture here is the title's. On main 8b957be, resource_at (views by address, #70/#71) makes its texture with device_x::create_placed_resource_x (real.rs:2359), so it takes the same place_pages / title_textures::register supersede path, and keeps it in MADE (real.rs:2367) holding the only reference, never released. That fits your 2,176 CreateShaderResourceView calls on old objects with none from the title, and the 17 % same-desc twins (0x04..0x08 padding in its key, #2762). #2743 traced the same growth to it. Counting creations by caller (title vs resource_at) would show what is left for the title.

    AI-assisted (Claude Code, Claude Opus 5.5).

  3. Natakout commented on Nov 26, 2026

    @Natakout
    Author

    Correction to this issue: most of the leaked objects are not the title's. They are the resources real::resource_at makes for device #70 / #71 (CreateShaderResourceView / CreateUnorderedAccessView of memory, with no resource object), which stay in its cache forever.

    I took the title's CreatePlacedResourceX calls apart from XCL's own (a local shell around the title's textures only):

    • up to 272 s, the title made 1,937 placed textures. vram::PLACED_TEXTURES had 46,761 entries, and there were 22,573 supersedes;
    • the rest come from resource_at. It keys its MADE cache by (address, desc) and never removes anything from it, so every superseded one stays alive with the reference that cache holds. That is why "the title never releases them": the title never had them.

    Experiment: when title_textures supersedes a resource that resource_at made, take it out of the cache and release it, through the hooked Release so late_release holds it until the GPU is past it. Over one 8-minute run:

    • 65,356 made, 39,367 released, 38,374 supersedes;
    • only 48 unmapped page targets still alive, against about 45,000 without it;
    • PLACED_TEXTURES stays at about 26,000.

    So that removes the leak. But it is not safe as it is:

    • with the bare release, the GPU hangs (0x887a0006) a few minutes into the world in 2 runs out of 2. A control run of the same build without it ran 480 s clean. The views the title made earlier still point at the released resource;
    • rewriting those views as null views first (3,421 of them, tracked per console handle) avoids the hang, but the title then crashes reading its own memory: 0xc0000005 in game_scarlett_master.exe+0x55ac280, read at 0x9cdb10000. So releasing such a resource has other side effects on the title's pages, through the cleanup in res_release (vram::forget, title_textures::forget, …).

    A real fix probably belongs in resource_at: reuse or evict its entries with the views that use them, rather than releasing behind them. Someone who knows how those views and the page sharing work should look at it.

  4. changed the title [-]D3D12.X: superseded placed textures stay alive (the title never releases them), memory grows ~8 MB/s in a retail world[/-] [+]D3D12.X: resources made by resource_at for views of memory (#70/#71) stay cached forever when superseded, memory grows ~8 MB/s in a retail world[/+] on Nov 26, 2026
  5. akimfomin commented on Nov 27, 2026

    @akimfomin

    Your update narrows the ownership question: XCL resource_at creates wrappers for both descriptor-by-address paths. AnyXboxX found a separate but useful accounting control on its Vice-Tay base. #466 counts unique bytes even for objects that cannot be evicted, separately from which owners permit disposal. Its eligible-victim policy would not be safe to transplant to XCL's COM lifetimes.

    A small public XCL check could repeatedly create SRVs/UAVs for one underlying range, count only registry-owned wrappers, and hold one external reference as its negative control. If you have a public candidate, give the PR and receiving SHA to your agent through PortBridge #98, or return the aggregate control in Test Lab. We can route the credited result back to the implementation owners. AI-assisted source comparison.

  6. Natakout commented on Nov 27, 2026

    @Natakout
    Author

    Duplicate of #2743, which found the same cause first. My numbers and a holder-aware eviction that ran 2 x 20 minutes clean are there now: #2743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions