Bug 497056 - Memory leak in kwin_wayland
Summary: Memory leak in kwin_wayland
Status: RESOLVED DUPLICATE of bug 496469
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 6.2.4
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-04 22:29 UTC by Maciej
Modified: 2025-01-29 14:40 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Stacktrace taken when memory leak increases (22.60 KB, text/plain)
2024-12-05 13:29 UTC, Maciej
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej 2024-12-04 22:29:13 UTC
SUMMARY
kwin_wayland takes 9 GB of memory when launching a Lutris game.

STEPS TO REPRODUCE
1. Launch World of Tanks inside Lutris/wine.
2. Wait till the game loads.
3. Sometimes it will make kwin_wayland take a lot of reserved memory.

OBSERVED RESULT

Before launching the game: 226 MB RSS
adam@fedora144:~$ ps aux | grep "kwin_wayland[ ]--"
adam       23105 28.7  1.4 4146252 226248 ?      Rl   17:03  23:37 /usr/bin/kwin_wayland --wayland-fd 7 --socket wayland-0 --xwayland-fd 8 --xwayland-fd 9 --xwayland-display :0 --xwayland-xauthority /run/user/1000/xauth_YWDazz --xwayland


After launching the game: 8293 MB RSS
adam@fedora144:~$ ps aux | grep "kwin_wayland[ ]--"
adam       23105 14.6 52.8 12318944 8293556 ?    Sl   17:03  53:02 /usr/bin/kwin_wayland --wayland-fd 7 --socket wayland-0 --xwayland-fd 8 --xwayland-fd 9 --xwayland-display :0 --xwayland-xauthority /run/user/1000/xauth_YWDazz --xwayland




SOFTWARE/OS VERSIONS

Linux/KDE Plasma: 6.11.10-300.fc41.x86_64
Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.10-300.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800H with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD Radeon Graphics

ADDITIONAL INFORMATION
Comment 1 Maciej 2024-12-04 22:34:15 UTC
May be related to #496698 since I use second monitor too, through HDMI from Nvidia GPU.
Comment 2 Maciej 2024-12-05 13:29:52 UTC
Created attachment 176368 [details]
Stacktrace taken when memory leak increases
Comment 3 Maciej 2024-12-05 14:02:23 UTC
I tried debugging with https://community.kde.org/KWin/Debugging#Debug_KWin_with_Valgrind
But the memory leak command gives Permission denied.

Same as:
```
adam@fedora144:~/Downloads$ dbus-run-session valgrind --log-file=kwinwayland.log --trace-children=no kwin_wayland
==254461== 
==254461== Warning: Can't execute setuid/setgid/setcap executable: /usr/bin/kwin_wayland
==254461== Possible workaround: remove --trace-children=yes, if in effect
==254461== 
valgrind: /usr/bin/kwin_wayland: Permission denied
```
Comment 4 Maciej 2024-12-07 15:40:24 UTC
Still leaking memory. Everyday 70% RAM and then system crash :(
Comment 5 Antonio 2024-12-07 22:31:31 UTC
Apparently, more people is having this issue, including me. As long as I have external monitors connected the system will eventually reach its full RAM capacity. The workaround is to disconnect and reconnect the monitors, that frees the memory, but causes performance issues until reboot.
Comment 6 Maciej 2024-12-15 14:08:19 UTC
Memory leak still exists. Just using firefox for an hour.
Then suddenly lag, screen flashes, logs me out and firefox gets killed.
I'm using the HDMI output in a dual-gpu laptop.
Comment 7 Intergalactic Narwhal 2024-12-17 14:38:37 UTC
Looks like I have the same issue. Just unplugging the external monitor doesn't work, I have to unplug it, then the actual replug fixes the issue.

❯ ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n | grep kwin
13796 MB		/usr/bin/kwin_wayland
4.60938 MB		/usr/bin/kwin_wayland_wrapper

❯ ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n | grep kwin
207.195 MB		/usr/bin/kwin_wayland
4.60938 MB		/usr/bin/kwin_wayland_wrapper

I'm using an Nvidia card as well, don't know what else to report, if you need more information from me, I can help of course.
Comment 8 Maciej 2024-12-17 21:22:28 UTC
I can confirm, that after unplugging and plugging HDMI *again* the memory leaks goes away.
Unplugging only doesn't fix the leak.
Comment 9 Antonio 2025-01-08 21:47:10 UTC
Still happening on 6.2.5, just using external monitors uses a lot of RAM on idle, around 8GB, and then the bug makes it go up to the maximum. In fact, after the update it happens more often.
Comment 10 Zamundaaa 2025-01-29 14:40:05 UTC
*** This bug has been marked as a duplicate of bug 496469 ***