Bug 501211 - Memory leak when window leaves full-screen 8 times or more
Summary: Memory leak when window leaves full-screen 8 times or more
Status: REOPENED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 6.3.2
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-08 05:52 UTC by qethanmoore+kde
Modified: 2025-03-28 04:29 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description qethanmoore+kde 2025-03-08 05:52:41 UTC
SUMMARY
When a window toggles full-screen many times, RAM usage attributed to kwin_wayland grows substantially.
Rebooting or kwin_wayland --replace returns RAM usage to normal. Closing all windows does not.

STEPS TO REPRODUCE
1. Open VLC, mpv, Firefox or any other program that can enter full-screen
2. Press the toggle full-screen button (usually F11 or 'f') exactly 16 times to observe the first memory leak and a lag spike
3. Leaving full-screen again (i.e. pressing toggle twice more) will leak much more memory each time

OBSERVED RESULT
Total RAM usage while testing with mpv looked like this:
1.7GiB to start, with video open and playing in a small window
16 full-screen toggles later: the first permanent increase to 1.9GiB
Subsequent times leaving full-screen: 2.5, 4.8, 14.3 GiB
(Going further exhausts my RAM entirely. Only holding the power button has any effect at that point.)

Other runs:
(kwin_wayland --replace)
[1.7,(16 full-screen toggles...) 1.8, 2.4, 4.8, 14.3] GiB
(and after a reboot)
[1.7,(16 full-screen toggles...) 1.9, 2.5, 4.9, 14.4] GiB

EXPECTED RESULT
RAM usage should be stable when a window cycles full-screen any number of times

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS 
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.13.5-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 2600X Six-Core Processor
Memory: 15.5 GiB of RAM
Graphics Processor: AMD Radeon RX 580 Series

ADDITIONAL INFORMATION
Closing the window after step 2 will also result in a lag spike.
Pressing alt+F4 before the 16th toggle avoids the problem, even if the window appears to leave full-screen for the problematic 8th time as it closes.
The issue is per window. I can drag a new tab from Firefox out into its own new window and it has the full 16 toggle capacity, independent of its originating window.
Another user has reported similar behaviour in coment 48 of bug id 496469; also an EndeavourOS user, but different hardware.
All other methods of toggling full-screen are affected. I avoided double-clicking videos because counting single key-presses feels more precise. It is always the 16th toggle on my machine measured this way.
Comment 1 Nate Graham 2025-03-11 21:53:43 UTC
I can reproduce this. Repeatedly full-screening LibreWolf (a Firefox fork) and leaving full screen does indeed cause kwin_wayland's memory usage to rise and then not fall again.
Comment 2 qethanmoore+kde 2025-03-12 23:53:14 UTC
I have upgraded my system and the problem is resolved, marking FIXED!

Operating System: EndeavourOS 
KDE Plasma Version: 6.3.3
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.13.6-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 2600X Six-Core Processor
Memory: 15.5 GiB of RAM
Graphics Processor: AMD Radeon RX 580 Series

Please check the above releases before reopening if you're still having trouble
Comment 3 qethanmoore+kde 2025-03-17 10:30:49 UTC
Oops, I guess I had a few good days, but it's definitely back exactly as it was. Real headscratcher

Operating System: EndeavourOS 
KDE Plasma Version: 6.3.3
KDE Frameworks Version: 6.12.0
Qt Version: 6.8.2
Kernel Version: 6.13.7-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 2600X Six-Core Processor
Memory: 15.5 GiB of RAM
Graphics Processor: AMD Radeon RX 580 Series
Comment 4 John Kizer 2025-03-28 04:29:33 UTC
For what it's worth, I can't reproduce this on my Fedora KDE 41 device (NVIDIA graphics) or on a KDE Neon VM (QEMU, software rendering).