ValveSoftware / csgo-osx-linux

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

Huge CS2 memory leaks #3687

Open RodolpheGohard opened 8 months ago

RodolpheGohard commented 8 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 8 months ago

anyone on this plz ? @kisak-valve

sixwheeledbeast commented 8 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 8 months ago

Its also related to this #3642

ZeroYamaoka commented 8 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 8 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 8 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 7 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 6 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 6 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 6 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 4 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 4 months ago

valve pls fix

Arcticzomb commented 4 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 4 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 4 months ago

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

luizluca commented 4 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 4 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 4 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 4 months ago
Extravi commented 4 months ago

image

Extravi commented 4 months ago

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

koreanfan commented 4 months ago

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

Extravi commented 4 months ago

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

same issue game is terrible on Linux

jakebottrall commented 4 months ago
nJ3ahxac commented 4 months 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 4 months ago

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

i agree

lxmadabc commented 3 months 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 3 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months ago

Would you mind posting your cs2 in-game settings?

sure. image image

resolution is 1920x1440 4:3 stretched.

nJ3ahxac commented 3 months 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 months 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 3 months 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 3 months 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

uczpre commented 2 months ago

Fedora 40 , KDE Plasma 6 , X11 , amd 7900 xtx , ryzen 7950x

Valve dumped the stable piece of software that is csgo for this mess. Its been 5 MONTHS ALREADY , this issue has resulted in me and my buddies getting sudden frame drops resulting in death or sometimes having our machines straight up freeze until we commence a force shutdown via power button. Me and my buddies have decided to quit CS2 altogether , and just play minecraft instead. I'll probably look into cs2 again after 3 or 4 years , when its much more stable (hopefully).

DavutHaxor commented 1 month ago

Issue still persists. Results in linux ending the process. It stutters after couple of mins in a deathmatch

koreanfan commented 1 month ago

After closed cs2 and steam my system eat 4.8-5GB RAM. So i need to use command "sudo sync && sudo sysctl -w vm.drop_caches=2" to free RAM

sylveonsylvia commented 1 month ago

the cause of this issue is probably the vulkan renderer since it happens on windows when using -vulkan aswell for me

luizluca commented 1 month ago

It only happens sometimes. It seems to be related to the vulkan compilation. If I let it build shaders before I launch the game (yes, it can take ages), the games works smoothly. However, if anything forces a new shaders build, I know I'll have problems.

nJ3ahxac commented 1 month ago

I went out and bought a 7900 XTX with 24gb of VRAM because I suspected that the problem was during mishandling of memory during overcommitment (needed new build anyway). When doing my own testing, I could see the issue remains, so this is not the problem. Memory and swap increases regardless of VRAM capacity.

P1's and Averages still decrease over time. With minimal settings, I saw roughly 200 1% lows drop to around 120 over the course of around 4 casual games, obviously memory increasing as time goes on as well. It's difficult to say where the problem stems from.

If I let it build shaders before I launch the game (yes, it can take ages), the games works smoothly.

I tested this today and I found it had no impact. You probably are confusing the smoothness gained from reduced shader compilation during gameplay with this issue.

HanM23 commented 1 month ago

OOM kills cs2 process after 30 minutes playing online :(

firashacker commented 1 month ago

Arch linux Hyprland

Computer Information: ``` Manufacturer: Gigabyte Technology Co., Ltd. Model: B760M DS3H DDR4 Form Factor: Desktop No Touch Input Detected Processor Information: CPU Vendor: GenuineIntel CPU Brand: 12th Gen Intel(R) Core(TM) i7-12700F CPU Family: 0x6 CPU Model: 0x97 CPU Stepping: 0x2 CPU Type: 0x0 Speed: 4800 MHz 20 logical processors 12 physical processors Hyper-threading: Supported FCMOV: Supported SSE2: Supported SSE3: Supported SSSE3: Supported SSE4a: Unsupported SSE41: Supported SSE42: Supported AES: Supported AVX: Supported AVX2: Supported AVX512F: Unsupported AVX512PF: Unsupported AVX512ER: Unsupported AVX512CD: Unsupported AVX512VNNI: Unsupported SHA: Supported CMPXCHG16B: Supported LAHF/SAHF: Supported PrefetchW: Unsupported Operating System Version: "Arch Linux" (64 bit) Kernel Name: Linux Kernel Version: 6.9.9-273-tkg-eevdf X Server Vendor: The X.Org Foundation X Server Release: 12401001 X Window Manager: Hyprland :D Steam Runtime Version: steam-runtime_0.20240610.91380 Video Card: Driver: AMD AMD Radeon RX 6600 (radeonsi, navi23, LLVM 18.1.8, DRM 3.57, 6.9.9-273-tkg-eevdf) Driver Version: 4.6 (Compatibility Profile) Mesa 24.1.3-arch1.1 OpenGL Version: 4.6 Desktop Color Depth: 24 bits per pixel Monitor Refresh Rate: 143 Hz VendorID: 0x1002 DeviceID: 0x73ff Revision Not Detected Number of Monitors: 1 Number of Logical Video Cards: 1 Primary Display Resolution: 1920 x 1080 Desktop Resolution: 1920 x 1080 Primary Display Size: 20.87" x 11.42" (23.78" diag), 53.0cm x 29.0cm (60.4cm diag) Primary VRAM: 8192 MB Sound card: Audio device: Realtek ALC897 Memory: RAM: 15819 Mb VR Hardware: VR Headset: None detected Miscellaneous: UI Language: English LANG: C.UTF-8 Total Hard Disk Space Available: 784795 MB Largest Free Hard Disk Block: 439470 MB Storage: Number of SSDs: 2 SSD sizes: 1000G,0B Number of HDDs: 0 Number of removable drives: 0 ```
Dazukodesu commented 1 month ago

Has anyone found a fix to this