protonscr

Unity Garbage Collector Memory Leak

protonopen Regression
ValveSoftware/Proton#9430 · opened 2026-01-24 by AdalynBlack · updated 2026-04-02 · 6 comments · github
AAdalynBlack 2026-01-24 github

Start at some point during Wine 9's development, a race condition was introduced that, when hit in any Unity app, the garbage collector becomes disabled permanently. This bug in Wine 9 also made its way into Proton 9, and has been around ever since. The exact cause of this race condition has since been identified in the corresponding wine bug report

I will leave the original bug report below, however, this issue spans beyond the original VNyan bug report

Compatibility Report

  • Name of the game with compatibility issues: VNyan
  • Steam AppID of the game: None

System Information

  • GPU: RTX 3070
  • Video driver version: 580.119.02
  • Kernel version: 6.18.5
  • Link to full system information report as Gist:
  • Proton version: Proton 9+

I confirm:

  • [X] That I haven't found an existing compatibility report for this game.
  • [X] That I have checked whether there are updates for my system available.

steam-default.log

Symptoms

Starting with Proton 9, VNyan has started regularly experiencing memory leaks on many systems. Sometimes a memory leak triggers within just a few minutes, and other times it can take hours. This memory leak appears to be framerate dependent, but potentially not resolution dependent. The memory leak shows up as affecting both VRAM and System RAM in VNyan's own reporting metrics. This issue is known to be present for many users, and is consistently resolved by downgrading to Proton 8.0-5. We've had repros on both AMD and Nvidia systems using both DXVK and WineD3D

Reproduction

  1. Install VNyan
  2. Add VNyan as a non-steam game
  3. Set VNyan to run in Proton 9 or higher
  4. Load an avatar into VNyan
    • I'm not sure if this step is necessary, but I haven't tested without an avatar yet
  5. Wait, potentially for a few hours. The memory usage will be very stable for some period of time
  6. Eventually, the memory usage will start going up linearly, at least a few MB/s, potentially up to 100 MB/s depending on the framerate

Here's a sample video where I caught the memory leak as it was happening to demonstrate the behaviour. The proton log linked above is from this same run. The memory was perfectly stable for about 40 minutes, until suddenly the memory started increasing

https://github.com/user-attachments/assets/a1ff6140-2c30-4519-82c3-e8aca823d7dc

AAdalynBlack 2026-01-27 github

after further debugging, we've determined the issue to be with Garbage Collection. For some unknown reason, Unity's garbage collector (BoehmGC) is unable to collect garbage fast enough. Unity's memory debugging tools show all of the leaked memory coming from "Reserved Managed Memory", which it describes as being memory that is allocated, but not used by any Unity objects

Image
AAdalynBlack 2026-01-28 github

we've been able to reproduce this issue on a fresh vanilla wine prefix. Wine 8 seems to be the most recent version that is unaffected by this issue

Iixvari 2026-02-05 github

Just to add to this issue. I have strong reason to believe that the same problem is happening with Warudo as well. With Proton 8, I observe no memory leak, but with Experimental (or anything newer than 8), there is a memory leak completely identical to this. I'm not sure about VNyan, but on Warudo, if you add PROTON_USE_WINED3D=1 to the launch options, it forces the memory leak to show up faster and makes the memory usage increase faster than without it.

AAdalynBlack 2026-02-05 github

The issue has been traced back pretty definitively for VNyan, and it's suspected to affect nearly every Unity program. The bug is related to syscall handling. VNyan triggers sleep syscalls ~5000x per second, as uOSC triggers sleeps ~1000x per second from busy waiting, and VNyan runs uOSC on 5 ports. Warudo also uses uOSC, which would explain it having the same issue

This is the relevant wine bug: https://bugs.winehq.org/show_bug.cgi?id=59333

We have a temporary fix for modern wine versions by patching Unity's garbage collector, and a proper fix in wine is being discussed actively

Mmadalee-com 2026-02-27 github

We suggest changing the title of this to something like "Leak in Unity Garbage Collection causes Full System to Hang".

While VNyan and Warudo are definitely affected by this, the issue spans to all of Unity in general. We've seen the same behavior out of a few games in Unity after playing them for extended time.

We wouldn't be surprised if this bug is causing issues for a significant portion of Unity Games running beyond Proton 8, and is the cause of countless unidentified crashes.

Hhoshinolina 2026-04-02 github

Fix patches backported to Proton are here. This is submitted upstream here, but hasn't been reviewed yet.

The bug dates back to the dawn of time, including Proton 8 and older versions. However, Proton/Wine 9 regressed it in a way that makes it much more likely to happen.

All Unity applications that use managed threads are affected. However, how likely it is to happen depends heavily on how many threads there are, how busy those threads are, and what specifically they are doing. The race likelihood is proportional to the number of Wine syscalls made per second across all managed Unity threads. VNyan happens to score the highest here (due to reliance on a very poorly designed polling thread loop in uOSC, across multiple instances). However, the bug has been definitively observed with at least Warudo and VTube Studio too.

In Wine/Proton 8 and older, only certain specific syscalls/flows could potentially trigger the race. Since Wine/Proton 9, it's every single syscall. I also suspect there is a different presentation, where the same general issue causes the GC to prematurely free an in-use object, which would cause application crashes instead of memory leaks. However, that one hasn't been identified definitively as happening in the wild, it's just theoretically possible.

I surmise that this has also hit people across huge numbers of Unity apps, it's just rare enough that likely most people never saw it consistently enough to identify it as a Proton issue and not, say, a random crash or app bug.

Proton versions

Launch options

Upstream links