ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
774 stars 69 forks source link

Huge CS2 memory leaks #3687

Open RodolpheGohard opened 6 months ago

RodolpheGohard commented 6 months ago

Your system information

Please describe your issue in as much detail as possible:

While I play, the memory consumption goes up without ever releasing, until crash. See this example where mem usage is 15.8Gb :

image

I have seen it use more than 24Gb RAM, starting to make my system unstable.

This happens while playing about ~1 ~2h. If the memory usage is too high my system becomes less stable and responsive, probably due to memory swapping, which makes the game unplayable then.

Steps for reproducing this issue:

  1. open game
  2. play
vonclutch commented 6 months ago

anyone on this plz ? @kisak-valve

sixwheeledbeast commented 6 months ago

I think it's covered in other bugs but yes. I am also having a memory leak issue. It seems to be only my account, a friends account did not have it on my machine so makes me suspect some setting. Also something about Overpass seems to trigger this eating memory, the character in the buy menu goes a red tint and memory is consumed until your in swap which makes the game unplayable. You have to close the game to release the memory.

ZeroYamaoka commented 6 months ago

Its also related to this #3642

ZeroYamaoka commented 6 months ago

My suggestion is change texture settings to low because memory leak is related to Vulkan when your GPU memory is overloaded it transfer some to ram memory

vonclutch commented 6 months ago

My suggestion is change texture settings to low because memory leak is related to Vulkan when your GPU memory is overloaded it transfer some to ram memory

Nah it's not from vulkan. I've got a clean install with xorg and gnome and still got the bug. I did downgrade my kernel from 6.6 to 6.1. not gonna say it's fixed it but it's 10 times better at least.

RodolpheGohard commented 6 months ago

Its also related to this #3642

The problems I experience don't exactly look like this.

Is there anything I can do / run to help diagnose this ? Also, This is the first game where I see this, I can run games like Final Fantasy or Doom Eternal Fine and they do fine, even though I am under the impression that they use vulkan and they have larger assets, larger maps to load.

simifor commented 5 months ago
Decided to compare linux vs windows with both dx11 and vulkan. I saw the following after spending ~90 minutes with each. Ram usage (just the game) Start Peak End
linux 2GB 6.4GB 6GB
windows dx11 5.1GB 7.8GB 5.8GB
windows vk 5.1GB 11.8GB 10.8GB

Configuration: Ryzen 5600G, RX 6600, 32GB of ram. Arch linux with stock kernel 6.8.2 and mesa 24.0.4, windows 10 with amd 24.3.1. The rest of my linux system took 3.5GB of ram, the rest of the windows system to 4.2GB.

It should be noted that dx11 actually ran with higher settings than the vulkan attempts because the settings reset and I didn't notice until I was done testing. DX11 was set to high preset, vulkan (both OSes) were set to medium preset, except with FSR disabled.

"End" was measured in the title screen. All 3 tests went through 7 different maps in the game in official servers. I'm not sure if there's anything in particular that makes the ram usage keep growing, map changes can increase it, but sometimes it remains the same. While I didn't see this in this session, last week cs2 took half of my ram on linux to the point my system started swapping due to having more things running in the background that time. Given that there were some updates from then to now, I don't know if the updates improved things or if this was down to luck.

Edit: On a different, 70 minutes long linux session, cs2's ram usage ballooned up to 12,8GB which then went down to 11,7GB when returning to the main menu. So despite being a somewhat shorter session, it ended consuming a lot more ram, twice as much as the previous one.

DavutHaxor commented 4 months ago

I dont live this issue anymore. My ram is idle but sometimes game gets lagged as if there is memory leak. When i play for some time like 2 or 3 hours

RodolpheGohard commented 4 months ago

I have lowered the texture quality.

It's better, I can run the game longer, but the issue is still there. Given enough time playing and changing maps, the memory usage builds up and the performance degrades, particularily on maps featuring water patches (Ancient and Anubis for example)

daniil-zilin commented 4 months ago

im having the same issue (memory leak) on Ubuntu 22.04.4 LTS (64 bit), Kernel Version: 6.5.0-28-generic, Driver Version: 4.6.0 NVIDIA 545.29.06, Driver: NVIDIA Corporation NVIDIA GeForce GTX 1660 SUPER

Arcticzomb commented 2 months ago

Same issue. After a few rounds my memory usage skyrockets from ~8GiB to ~20GiB, eventually causing frame loss, stuttering and frame drops while shooting and getting shot, and eating into swap memory. I have also noticed that all 8GB of vram gets used up immediately as well as near 100% GPU usage at all times.

All settings are on high, Windows shows none of these issues.

System: Arch Linux 6.9.7-zen1-1-zen GPU: NVIDIA GeForce RTX 3070 Ti Driver Version: NVIDIA 555.58 DE: KDE 6.1.2 WM: Wayland

Extravi commented 2 months ago

valve pls fix

Arcticzomb commented 2 months ago

Cont. of my previous comment

Same issue. After a few rounds my memory usage skyrockets from ~8GiB to ~20GiB, eventually causing frame loss,

I did a fresh install of Arch which seems to have solved this issue. I have no clue whether it's a user space or system space configuration issue. I switched through a few maps with bots, playing a few rounds each, and memory went and and down as expected from the base game. It averaged ~6.6GiB sometimes going higher before coming back down.

Edit: After 2 wingman matches my memory is steadying out at ~11GiB. Memory only seems to be majorly affected when playing multiplayer

Edit 2: Nope, issue not fixed. After playing another round I jumped to 16 GiB usage and low frames when shooting/others shot.

Edit 3: So, it seems that at the start/very end of every round the game allocates ~.1 GiB of memory. This still applies to both multiplayer and playing vs bots locally. Ignore the second sentence from the first edit.

ghjnut commented 2 months ago

Here's my metrics from node-exporter. Just before 01:00 is when I started CS2 and played two matches (until just after 02:00) image

❯ neofetch
                   -`                    ghjnut@derek.jaked.in
                  .o+`                   ---------------------
                 `ooo/                   OS: Arch Linux x86_64
                `+oooo:                  Kernel: 6.9.9-arch1-1
               `+oooooo:                 Uptime: 12 hours, 42 mins
               -+oooooo+:                Packages: 1149 (pacman), 47 (flatpak)
             `/:-:++oooo+:               Shell: bash 5.2.26
            `/++++/+++++++:              Resolution: 3840x2160
           `/++++++++++++++:             DE: GNOME 46.3.1 (Wayland)
          `/+++ooooooooooooo/`           WM: Mutter
         ./ooosssso++osssssso+`          WM Theme: Adwaita
        .oossssso-````/ossssss+`         Theme: Adwaita-dark [GTK2/3]
       -osssssso.      :ssssssso.        Icons: Adwaita [GTK2/3]
      :osssssss/        osssso+++.       Terminal: tmux
     /ossssssss/        +ssssooo/-       CPU: AMD Ryzen 7 5800X (16) @ 3.800GHz
   `/ossssso+/:-        -:/+osssso+-     GPU: NVIDIA GeForce RTX 3070 Ti (v555.58.02)
  `+sso+:-`                 `.-/+oso:    Memory: 12237MiB / 64217MiB
 `++:.                           `-/+/
 .`                                 `/
koreanfan commented 2 months ago

debian-testing, rx580, memory leak at online matchmaking with other players

luizluca commented 2 months ago

For those affected, it would be nice to list:

The leak is probably not affecting the Steam Deck env (they might have tested it for more than 2 hours). So, it might be something not used there.

Fxzzi commented 2 months ago

Memory leak occuring on my end, causing fps to slowly tank as well whilst playing. Using streched res, vulkan, and native wayland enabled in cs2.sh

Disabling these options and reverting to a fully stock vulkan cs2 does not help.

nJ3ahxac commented 2 months ago

Disabling swap helps at least for me since I'm still on a 400MB/s SSD. Memory pressure builds until the implications on performance make the game unplayable, with sprays and executes at 30 FPS. Results in oom kill once it hits my max of 16gb (around an hour in).

Tested with Mesa 22.3.6 - also present.

I'm not sure about the posts before this week but given many noticed this issue recently, surely this must be a recent cs2 regression?

Extravi commented 2 months ago
Extravi commented 1 month ago

image

Extravi commented 1 month ago

steam support said we should submit the issue here: https://github.com/ValveSoftware/steam-for-linux/issues

koreanfan commented 1 month ago

also pc freeze in cs2 main menu for 5-10 seconds

Extravi commented 1 month ago

also pc freeze in cs2 main menu for 5-10 seconds

same issue game is terrible on Linux

jakebottrall commented 1 month ago
nJ3ahxac commented 1 month ago

Tested with separate hardware with mostly identical software, settings on High:

14600KF + 7900 XTX (24GB VRAM) 5600x + 6600 (8GB VRAM)

For the 6600, we saw a massive increase in RAM with VRAM topping out at 7gb. For the 7900 XTX, we saw little to no increase in RAM, with vram topping out at 11gb. No performance degradation for the 7900 XTX. Massive degradation for the 6600.

I'm going to speculate that the problem is some kind of logic error regarding memory over-commitment. These slides about the vulkan specification at page 24 describe the specifics of memory management in a constrained scenario. Depending on the driver the system might allocate RAM instead of VRAM and naturally this degrades performance. The slides explicitly state what we encounter.

I don't want to speculate much further but it's likely that in this scenario memory which is not allocated to VRAM is marked as failing to allocate, despite the fact that it does, resulting in a steady memory leak. This seems to only occur once VRAM is topped out to ~85% of its maximum size.

Extravi commented 1 month ago

Replying to https://github.com/ValveSoftware/csgo-osx-linux/issues/3687#issuecomment-2241503860

i agree

lxmadabc commented 1 month ago

R5 5600G + RX 6650 XT (8 GB VRAM) + 16 GB RAM Manjaro with stock 6.10 Kernel (just did a reinstall, had the same problem before and for a while)

I usually get through one full game fine, if I do not restart CS afterwards, I get freezes during the second game. If I'm not quick in restarting CS, the system fully crashes and only power off works.

Arcticzomb commented 1 month ago

After playing some surf and then a single game of wingman on Memento. 2024-08-07-131602_screenshot This ss is from System Monitor while in the main menu of CS2 app name, cpu%, memory, and upload

sixwheeledbeast commented 3 weeks ago

This may help some people. I don't believe the steam client tells sniper runtime to use the beta version automatically. I was looking through all the settings trying to work this out. As on the same hardware I have different results on two accounts. I seemed to have stopped this memory leaking from selecting the beta for sniper in steam. I am running the beta steam client. If this is the issue it would be sensible if sniper could detect that the client is the beta version and update accordingly. FPS and general buggy-ness has also improved greatly. ~30-60FPS to ~160-230.

nJ3ahxac commented 3 weeks ago

I seemed to have stopped this memory leaking from selecting the beta for sniper in steam. I am running the beta steam client.

Unfortunately I couldn't replicate this.

Arcticzomb commented 3 weeks ago

I seemed to have stopped this memory leaking from selecting the beta for sniper in steam. I am running the beta steam client.

How long did you play for? If you just booted up the game without testing, try playing a few matches through then check application ram usage and try, for example, spraying negev at the X on the wooden wall behind the bar in memento.

Extravi commented 3 weeks ago

after one game of office gtx 1650 mobile image and vram used out of 4gb image and cs2 process memory image

to really notice the lag and memory leak you need a gpu without lots of vram

I think this is the issue https://github.com/ValveSoftware/csgo-osx-linux/issues/3687#issuecomment-2241503860

sixwheeledbeast commented 3 weeks ago

How long did you play for?

Several hours of casual, I am not going to suggest it worked for me without testing.

Arcticzomb commented 3 weeks ago

Several hours of casual, I am not going to suggest it worked for me without testing.

My bad for assuming. I can't say that switching the steam client and runtime sniper to their respective beta branches works though. I still notice a steady increase of ram that never decreases with every match I play.

As stated in my comments above I am running (updated): System: Arch Linux 6.10.5-zen1-1-zen (64-bit) GPU: NVIDIA GeForce RTX 3070 Ti Driver Version: NVIDIA-dkms 555.58.02-1 DE: KDE 6.1.4 WM: Wayland

Fxzzi commented 3 weeks ago

image

Here is my ram and vram stats after playing a bit of surf and then a deathmatch game in overpass.

I am running with an nvidia gpu, native wayland, and beta sniper. Seems much better than before.

nJ3ahxac commented 3 weeks ago

Here is my ram and vram stats after playing a bit of surf and then a deathmatch game in overpass.

Would you mind posting your cs2 in-game settings?

Fxzzi commented 3 weeks ago

Would you mind posting your cs2 in-game settings?

sure. image image

resolution is 1920x1440 4:3 stretched.

nJ3ahxac commented 3 weeks ago

Thanks, would you mind retesting with model detail set to high? I have similar performance results when I use those settings but I'm fairly sure the only reason is because the lack of model detail results in less vram usage, so it's much harder to run into a scenario where vram increases to a point where the driver considers it overcomitment. It does still happen, but you will need to play for ~4 hours of 10v10 instead of ~30 minutes for it to reach a point where it is blatantly obvious.

(sry, this part meant for @sixwheeledbeast) I noticed you said you had two different accounts - it's possible that a settings difference causes the disparity, so please double check that if it's convenient

Fxzzi commented 3 weeks ago

I never mentioned having two accounts (I do, but I have a 1600 day old VAC ban on one lol)

I can try with model detail set to high when I can.

bambi42 commented 2 weeks ago

I have the same Issue. The RAM usage just increases steadily and at some point the game just crashes upon joining a match. FPS also get worse over time, and the low points are always when shooting.

Fedora 39 KDE X11
Ryzen 5 3600
Nvidia GTX 970
32GB RAM
CS2 Video Settings: Medium

Fxzzi commented 2 weeks ago

would you mind retesting with model detail set to high

Tested this last night. Yes it's much worse. My FPS is very unstable and my FPS slowly decreases as I play. I had to switch graphics settings half way through the game because of how unplayable it became