Repository navigation
Description
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_lockeddefers 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 runspump(), 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
vkAllocateMemoryof 4 MiB or more with its caller. In 17 seconds there were 1,422 allocations totalling 14,220 MiB, all fromretain_locked, called througha_retain_statefrom 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
retagjob cannot show this: it calls the test hookdrain(), and the testcounters()callpump()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.
Activity
RR runtime: free released input copies while no instance exists
Release 0.6.1: version 0.6.1 and its release notes