Bug 498627 - Huge kwin_wayland memory leak
Summary: Huge kwin_wayland memory leak
Status: RESOLVED DUPLICATE of bug 496469
Alias: None
Product: kwin
Classification: Plasma
Component: performance (other bugs)
Version First Reported In: 6.2.5
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland-only
Depends on:
Blocks:
 
Reported: 2025-01-13 20:31 UTC by Kubek4155
Modified: 2025-01-29 17:56 UTC (History)
6 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kubek4155 2025-01-13 20:31:01 UTC
SUMMARY
When using an external monitor on a dual gpu laptop (iGPU + dGPU) a process kwin_wayland uses huge amounts of memory. The speed of its rise seems to depend on how many pixels were changed. It rises significantly faster when gaming or playing a video and nearly doesn't when just displaying the wallpaper. It usually goes to 8-11GB after an hour. I haven't noticed it going above 11GB even after 3 hours.  

STEPS TO REPRODUCE
1. Pick a laptop with a dGPU
2. Connect an external monitor
3. Use the laptop for a bit

OBSERVED RESULT
Kwin using a lot of memory

EXPECTED RESULT
Kwin not using a lot of memory

SOFTWARE/OS VERSIONS
Linux: 6.12.9-arch1-1
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1

ADDITIONAL INFORMATION
Laptop: Lenovo Legion 16irh8
Cpu: Intel Core i5 13500h
Gpu: Nvidia RTX 4050 Mobile
Ram: 16GB 
It doesn't happen when an external monitor is not connected, when the iGPU is turned off in the bios and when nvidia drivers are not installed.  Disconnecting the monitor while working stops the rise but it stays at the same level. Connecting it back restarts plasma and resets kwin_wayland's memory usage but it goes back even faster than it did the first time.
Comment 1 Vlad Zabotinsky 2025-01-15 11:07:08 UTC
Same problem for me on Tumbleweed laptop with 3050 mobile
Comment 2 Eternity 2025-01-17 23:31:08 UTC
I am having the same problem on my Arch Linux HP OMEN 15-ce0xx laptop with two external displays connected via HDMI and Mini DisplayPort. My system has 32GB of memory installed (the maximum for this system); using Mission Center I measured `kwin_wayland` to be using 23.6GiB of memory (a number from a few days ago, the highest I've recorded).

I have found success at clearing the used memory by either **temporarily disconnecting the external displays** long enough for the system to move all my windows to the built-in display before reconnecting them (I usually wait for the system to play a notification before unplugging/re-plugging another display, the memory only shows as cleared once all the displays are reconnected for some reason). I have also found success by briefly switching to a Virtual Terminal (e.g. VT3 with `Ctrl+Alt+F3`) for a couple seconds to a minute (I have had discord and VSCode close on me when switching to a VT once or twice, though that may be unrelated.)

While I do tend to leave my computer running for extended days at a time with a lot of Firefox tabs open (using 4.65GiB of memory while `kwin_wayland` used 23.6GiB), I don't think that should change the fact that it is filling my memory fairly quickly (dropping from 13.3GiB to 413MiB, before growing to 1.13GiB over the course of 4 minutes after reconnecting the displays, rising at a rate of about 2.5MiB per second. I measured these as I was writing this.)

SOFTWARE/OS VERSIONS
Linux: 6.12.9-arch1-1
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1

ADDITIONAL INFORMATION
Laptop: OMEN by HP Laptop 15-ce0xx
CPU: Intel i7-7700HQ (8) @ 3.800GHz
GPU: NVIDIA GeForce GTX 1050 Ti Mobile
RAM: 32GB

Unlike Kubek4155, I haven't modified my NVIDIA drivers or disabled any of my graphics cards in the BIOS when troubleshooting the bug on my system (I am unsure if I can even do so in my BIOS.)

I apologize if my addition to this bug report is unnecessary or unhelpful, I am new to daily driving a Linux system and thought I should share my two cents on this problem as I'm getting tired of my memory utilization constantly hitting 99%.
Comment 3 qwer1234tyuiop 2025-01-18 20:05:21 UTC
I have the exact same issue on my PC with the similar iGPU + NVIDIA GPU setup with external monitor as well. The memory leak is RAM and not VRAM that happens in other bug report, so they seems like are irrelevant cases.

Observation:
- Memory will increase only when external monitor is plugged in
- Memory will increase by about 2mb for every interaction that i do on the desktop, like keep clicking on the date to show and collapse calendar, the memory will forever increase without release
- Memory will leak even more when gaming, seems to align with up's observation

Workaround:
- Unplugging and replugging the external monitor cable (turning off and back on with monitor power button seems useless)
- Logout from the desktop and login again (not lock screen)

PC specifications:
Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.8-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i9-12900H
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Iris® Xe Graphics
Manufacturer: Acer
Product Name: Predator PH315-55
System Version: V1.12

I have seen it rolled up to 22Gb of RAM usage alone, and i think this bug is really critical because what if a person is running kde plasma on a 16gb ram computer or even 8gb? this person's PC will very soon reach insufficient memory and interrupted his normal use of the computer, not everyone has a 32 gb or 64 gb ram PC to  go with the memory leak.

Hope this can help with the bug fix and get it delivered to users soon. I am new to KDE and really love it so much and want it to be even better.
Comment 4 Eternity 2025-01-18 20:18:02 UTC
I'm just adding that my RAM is filling rather than my VRAM (assuming this bug was originally addressing VRAM). As I'm writing this comment, my RAM is at 93% utilization (kwin is using 14.8GiB) while my iGPU's VRAM is at 8% utilization with my dGPU at 1%.
Comment 5 Eternity 2025-01-18 20:28:18 UTC
Also, as this bug seems to be affecting both Arch Linux and Fedora, I'm changing this bug from Arch Linux (now Fedora RPM) to unspecified as I couldn't find an option for "generic linux" or "all platforms"
Comment 6 Stefan 2025-01-25 19:50:45 UTC
I am having the same issue, but it only started to happen like 2 weeks ago.
For me it doesn't stop going up until my ram is full and it eventually restarts my desktop.

Below is some info about my system if it helps.

OS: Arch Linux 
Host: Swift SFX14-71G (V1.51)
Kernel: Linux 6.12.10-arch1-1

CPU: 13th Gen Intel(R) Core(TM) i7-13700H (20) @ 5.00 GHz
GPU 1: NVIDIA GeForce RTX 4050 Max-Q / Mobile [Discrete]
GPU 2: Intel Iris Xe Graphics @ 1.50 GHz [Integrated]
Comment 7 Zamundaaa 2025-01-29 17:56:11 UTC

*** This bug has been marked as a duplicate of bug 496469 ***