https://bugs.kde.org/show_bug.cgi?id=517670

            Bug ID: 517670
           Summary: win_wayland leaks hundreds of MB memory per min while
                    screen is locked, leading to OOM
    Classification: Plasma
           Product: plasmashell
      Version First 6.6.2
       Reported In:
          Platform: Fedora RPMs
                OS: Linux
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: Screen locking
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: 1.0

Created attachment 190722
  --> https://bugs.kde.org/attachment.cgi?id=190722&action=edit
OOM dump showing kwin_wayland at 37GB RSS with full process memory table

***
If you're not sure this is actually a bug, instead post about it at
https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see
https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
When in lock screen the system accumulates hundreds of MB memory per minute.
Over a work day of leaving and coming back to the system this eats up a lot of
RAM and swap. I run data analysis so occasionally load upwards of 30 GB of data
into memory. However,  the accumulated memory from win_wayland then results in
the OOM killer targeting kwin_wayland and destroying the Wayland session. The
system sometimes re-logs and sometimes reboots. The lock-screen leak stops
immediately upon unlock but memory is never reclaimed, thus the system crash.

STEPS TO REPRODUCE
1. Log into Plasma Wayland session
2. Open applications (Zed browser, Slack, Zen editor, Thunderbird). Each one
tested in isolation does not result in excessive RAM usage.
3. Lock the screen (either manually or via auto-lock)
4. Monitor kwin_wayland RSS via: `ps -C kwin_wayland -o rss=`
5. Wait 5+ minutes and observed log

OBSERVED RESULT
kwin_wayland RSS grows at a steady rate, around 350MB/min while the screen is
locked. The leak is precisely correlated with the lock screen being active. It
starts immediately on lock and stops immediately on unlock, but memory is never
freed. Over a few hours this consumes all available RAM and swap, leading to
OOM.

I'm fairly new to Linux so I had Claude Code help me investigate a little, by
suggesting some commands. I was able to compile this, hopefully its helpful.

System crashed this morning because of this, OOM incident from today: 
  kwin_wayland pid=13943 total_vm=10024388 pages, rss=9356730 pages (35.7GB)
  rss_anon: 9,331,501 pages (35.6 GB)
  rss_file: 12,065 pages (47 MB)
  rss_shmem: 13,164 pages (51 MB)
  pgtables_bytes: 76,374,016 (72.8 MB)
  swapents: 27,648 pages (108 MB)

System state at time of OOM:
  Free RAM: ~417MB (of 64GB)
  Free swap: 196kB (of 8GB — effectively zero)
  Active anonymous: 37.3GB
  Inactive anonymous: 19.8GB

Full kernel OOM output:
  kernel: krunner_placesr invoked oom-killer:
gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|GFP_COMP), order=0, oom_score_adj=200
  kernel: Out of memory: Killed process 13943 (kwin_wayland)
total-vm:40097552kB, anon-rss:37326004kB, file-rss:48260kB, shmem-rss:52656kB,
UID:1000 pgtables:74584kB oom_score_adj:200
  kernel: oom_reaper: reaped process 13943 (kwin_wayland), now anon-rss:844kB,
file-rss:48260kB, shmem-rss:52656kB

Then, after testing found that this behaviour stops as soon as unlocking the
lock screen.

Active use timeline showing this:
16:24:49 kwin_rss=1582MB  (apps running normally)
16:25:49 kwin_rss=1536MB  (killed some apps as test)
16:26:49 kwin_rss=1536MB  (flat - no leak during active use)
...
16:34:49 kwin_rss=1538MB  (still flat after 10 min of active use)
17:04:39 kwin_rss=1517MB  (screen locks, walk away)
17:07:39 kwin_rss=1660MB  (leak starts)
...
17:13:49 kwin_rss=3176MB  (unlocks screen)
17:28:49 kwin_rss=4471MB  (Regular during 35 min of active use)

Since leaving work (ssh in, screen still locked):
20:00:56 kwin_rss=1314MB 
20:15:56 kwin_rss=4872MB 
20:30:56 kwin_rss=9262MB 
20:45:56 kwin_rss=13652MB 
21:00:56 kwin_rss=18024MB

I tested that leak is not caused by any one specific application. Closed Zed,
Zen Browser, Slack, Thunderbird, Proton Bridge, and Remmina individually and in
combination. The leak only correlates with lock screen state.

Was on Orchis-dark theme. Changed this between Breeze Dark and Fedora Dark with
no effect. 


EXPECTED RESULT
kwin_wayland memory should remain stable while the screen is locked.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
- OS: Fedora 43
- Kernel: 6.19.7-200.fc43.x86_64
- KDE Plasma version: 6.6
- kwin version: 6.6.2-2.fc43
- plasma worksapce version: 6.6.2-1.fc43
- GPU: NVIDIA GeForce RTX 3060 Ti 8GB
- NVIDIA Driver: 580.126.18
- Monitors: Dual monitor setup (DP-1 portrait 1920×1080, DP-2 landscape
2560×1440 primary)

ADDITIONAL INFORMATION
The leak rate is consistent at ca. 350MB/min regardless of what other
applications are running.

Probably unrelated but I'm using Krohnkite tiling window manager and Tailscale. 

This may be related to [Bug
496469](https://bugs.kde.org/show_bug.cgi?id=496469), which says this was
resolved with NVIDIA driver 570.153.02. However, I am on driver 580.126.18
(which should include that fix) and still experiencing the leak, plus I'm using
only a single GPU.

My setup also differs from most reports in that bug:

- Single GPU, no iGPU
- The trigger is the lock screen, not sleep/resume
- No cables are being disconnect required. The leak starts purely from the
screen locking

I suspect the lock screen turning the displays off and on may trigger the same
underlying issue through a different path that wasn't covered by the earlier
fix, but its out of my technical depth to understand exactly whats going on
here.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to