ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.22k stars 174 forks source link

steamwebhelper causes memory leak shortly after opening game #11000

Open JerryDELUXE opened 3 months ago

JerryDELUXE commented 3 months ago

Please describe your issue in as much detail as possible:

When I just open steam the memory usage is fine, but when I open a game (In this case Half-Life 2) steamwebhelper starts using more and more memory until the whole computer freezes for a few seconds and the system automatically kills steam. I used to be able to fix it by turning off GPU acceleration for web views but that doesn't work anymore. This apparently was able to fixed by opening steam by running steam -no-browser but according to the Valve Developer Community this parameter was deprecated. This issue seems to have existed for a really long time, and removing the way to "fix" it certainly isn't helpful.

Steps for reproducing this issue:

  1. Open Steam
  2. Launch game
  3. Wait a few minutes (This step being sped up by loading screens)
JerryDELUXE commented 3 months ago

I found a temporary fix for this issue.

If you have installed Steam through a Flatpak, you can run this command in order to open it with it's memory usage limited to 38 MiB: ( ulimit -m 384800; flatpak run com.valvesoftware.Steam ) If you installed it through traditional packages (Such as RPMs), you can run this command: ( ulimit -m 384800; steam ) Keep in mind that I haven't tested the second method, but it should work perfectly fine.

JerryDELUXE commented 2 months ago

I found a temporary fix for this issue.

If you have installed Steam through a Flatpak, you can run this command in order to open it with it's memory usage limited to 38 MiB: ( ulimit -m 384800; flatpak run com.valvesoftware.Steam ) If you installed it through traditional packages (Such as RPMs), you can run this command: ( ulimit -m 384800; steam ) Keep in mind that I haven't tested the second method, but it should work perfectly fine.

Doesn't seem to work anymore, so I'm completely incapable of playing any of the games I spent money on

rantvm commented 1 month ago

I experience a similar problem when playing certain games (Fallout 4) for an hour or two on Ubuntu 22.04 LTS. Problem is particularly noticable if I wake up the system after a period of inactivity. I cannot confirm whether the problem is Steam or something more general at this time, but I'll do a few tests this week to see if I can't rule out Steam.

While playing, I am observing RAM at 95-99% of maximum, but there isn't any processes that would account for the >30GiB of used RAM. Total RAM occupied as reported by sudo ps axeo rss | tail -n+2 | paste -sd+ | bc is in the ~12 GiB range while playing Fallout. Running kill -9 $(pgrep steamwebhelper) generally alleviates the problem for 30 to 45 minutes, but the problem recurs and sometimes the game crashes. After exiting game, memory usage remains high (in the 20+ GiB range).

While investigating, I found this thread and answer on AskUbuntu. Running the command (echo 3 | sudo tee /proc/sys/vm/drop_caches) a number of times resolves the problem. According to the answer explanation/manpage, writing 3 to the drop_caches file causes a cache cleanup to take place.

I don't know whether this is a problem with Steam or Linux in general, but starting Big Picture immediately occupies ca. 1.5 GiB of RAM of which ca. 1 GiB is immediately released upon running the above command on my system. At this time, a workaround may be to set up a script to run the command periodically (every 1 to 5 minutes) while Steam is running.

If someone is able to provide instructions for profiling the RAM usage across all the processes, I can dedicate some hours of my time during the weekend for that.

JerryDELUXE commented 4 days ago

I deleted a bunch of cache files, then the issue was seemingly resolved, as it seems the steamwebhelper process isn't even even running anymore (but all the menus and such still work perfectly fine). image But this issue still shouldn't be closed as this very well could be temporary and that it's very likely that deleting those caches had nothing to do with it.