mastercomfig / tf2-patches

Team Fortress 2, but with a lot of fixes, QoL improvements and performance optimizations!
Other
218 stars 27 forks source link

TF2 & TC2 leaks memory when connected to any server on wine & proton. #660

Open ghost opened 1 year ago

ghost commented 1 year ago

Description

When running tf2 or tc2 inside wine (wine-stable, wine-staging, proton, etc..) and being connected to any server tf2 will allocate memory every second (or frame, tick, etc) until OOM. This issue is not present when running on windows. This issue is not present when unconnected.

Checklist

Reproduction

  1. Install steam (with chromium fix) & tf2 inside wine or use native steam client & proton tf2
  2. Start tf2
  3. Connect to any server, for example local itemtest
  4. Check how memory usage increases through either wine's taskmgr or in-game console command "memory" (check Heap Used:)

Screenshots

Example memory usage in tc2 after 30 minutes of afk Screenshot_20230822_122742

Setup Details

Client Settings

ghost commented 1 year ago

Probably this allocation is being done each frame, because when i capped my fps at 66 it was allocating much slower.

ghost commented 1 year ago

looks like a memory leak in VGUI, found multiple vgui staticClientDLLToolsPanel strings in memory chunk with leaked memory and a lot of repeated data "F..Ѫ.....øÚ¬..... É..p¶Ö.|.." (hex: 46 09 04 D1 AA 0E 00 00 00 00 F8 DA AC 0E 00 00 00 00 A0 C9 8B 0E 70 B6 D6 0E 7C 07 01) with 1 char difference on each.

ghost commented 11 months ago

Setting r_drawvgui to 0 (requires sv_cheats 1) stops tf2 from leaking its memory, but doesn't clean leaked memory. Something is broken with VGUI on wine

ghost commented 11 months ago

Found a potential leak location https://github.com/mastercomfig/tf2-patches/blob/adce75185fe5822309f356424ea449dee029e2d8/src/engine/vgui_baseui_interface.cpp#L932C23-L932C23

ghost commented 11 months ago

Found a potential leak location https://github.com/mastercomfig/tf2-patches/blob/adce75185fe5822309f356424ea449dee029e2d8/src/engine/vgui_baseui_interface.cpp#L932C23-L932C23

No, the leak remains, or I built the project incorrectly, I don’t know for sure.

I give up, I have no idea where in VGUI this memory leak occurs, and why it only happens inside wine... I'll leave this thread open, maybe someone else can find the root of the problem