Skip to content

RR runtime leaks about 1 GB/s of VRAM while RR is available but off: released input copies are never freed without an evaluate #8

Closed

Description

@j0nsh1n

What happened

With the RR plugin loaded and RR reported available, Cyberpunk 2077's video memory grows by about 1 GB a second from the main menu, even with Ray Reconstruction switched off in the game. Within 15 to 25 seconds the system runs out of memory. On Linux the OOM killer then took down the desktop session.

Cause, in clean/rr_f/runtime/src/rr_runtime.cpp:

  • The game tags the RR inputs every frame. For each lifetime-0 input, the plugin copies the texture (retain_transient, retain_locked) and releases the previous copy when the input is tagged again.
  • release_transient_locked defers the release (defer_release) until the copy's command list has run.
  • The deferred list is emptied only by pump(), which runs in instance create, evaluate and destroy. With no RR instance, nothing ever runs pump(), so every released copy stays allocated. Here that is two 1706x960 RGBA16F copies a frame, about 13 MB each.

Evidence:

  • A diagnostic vkd3d-proton build logged every vkAllocateMemory of 4 MiB or more with its caller. In 17 seconds there were 1,422 allocations totalling 14,220 MiB, all from retain_locked, called through a_retain_state from the RR plugin's tag handler.
  • Reproduced without the game in rr_test_host, with a job that copies and releases one 1706x960 input per frame, with no instance, no evaluate and no test drain. Over 200 frames, video memory grows by +2,635 MiB.
  • The existing retag job cannot show this: it calls the test hook drain(), and the test counters() call pump() too.

This is not specific to Proton. It should happen on Windows whenever a game tags RR inputs while RR is off.

Suggested fix

Call pump() in release_transient_locked after defer_release(r, rt.serial);, so copies whose frames have completed are freed at once. With that change, the same 200-frame test grows by +37 MiB. In game, VRAM levels off at about 8.9 GB, and RR ran 15,203 evaluates with no failures in a 6.5-minute session.

A regression test needs to measure video memory, for example QueryVideoMemoryInfo before and after, not the test counters, which pump.

Game and settings

  • Game and version: Cyberpunk 2077 (Steam), current build
  • Upscaler chosen in the game's settings, and its quality mode: DLSS, Quality
  • Resolution, Ray Reconstruction on or off, its mode: 2560x1440. The leak happens with RR off; RR on works after the fix (fast and accurate).

System

  • WrongGPU version: 0.6.0 (runtime rebuilt from source)
  • GPU and AMD driver version: RX 9070 XT, RADV (Mesa 27.0.0-devel)
  • Windows version: none. Linux (Nobara), GE-Proton 11-11
  • OptiScaler: the WrongGPU edition from the launcher (10.0.0-pre1)

Logs

From wronggpu-rr.log: runtime: RR runtime ready ... (driver-channel self-test passed, 150 kernels ...), diag: support query RR (1001) ... answer 0 (yes) and diag: RR set-loaded(true): answer 0. The growth starts right after these, with no RR instance created.

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