Bug 483538 - [Wayland] VRAM leak when repeatedly switching between window icons
Summary: [Wayland] VRAM leak when repeatedly switching between window icons
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 6.0.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6, wayland-only
Depends on:
Blocks:
 
Reported: 2024-03-14 12:04 UTC by aidas957
Modified: 2024-12-29 21:41 UTC (History)
6 users (show)

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


Attachments
Heaptrack Consumed (349.23 KB, image/png)
2024-04-21 20:13 UTC, vindicator
Details
Heaptrack Top-Down (450.66 KB, image/png)
2024-04-21 20:14 UTC, vindicator
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aidas957 2024-03-14 12:04:12 UTC
SUMMARY

So the VRAM usage leaks when repeatedly switching between window icons in the taskbar (I tested this with Konsole windows)

I first noticed the issue when my RAM usage was unusually high on KDE 6 (so I checked radeontop and the GTT usage was over 3 GB which shouldn't happen in normal usage)

So I did some testing and noticed that issue only happens in that scenario above (I did some more testing and noticed that disabling the 2 window options in Icons-only Task Manager prevents the VRAM leak)

Hopefully this bug isn't Mesa-specific though (because I haven't tested a NVIDIA-only setup)

STEPS TO REPRODUCE
1. Launch KWin Wayland
2. Make sure the 2 window options in Icons-only Task Manager are enabled
3. Open 2 Konsole windows (other apps should be fine too)
4. Hover over the 2 Konsole icons to generate the thumbnails
5. Click repeatedly between the 2 Konsole icons to switch between those Konsole windows (I think there's an unrelated segfault but the VRAM leak should be visible before then)

OBSERVED RESULT

The VRAM usage keeps growing with no limit (I managed to hit the 8 GB GTT limit)

EXPECTED RESULT

The VRAM usage should mostly stay the same

SOFTWARE/OS VERSIONS
Linux: 6.7.9-arch1-1
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Mesa Version: 24.0.2
PipeWire Version: 1.0.3
Comment 1 Fushan Wen 2024-03-14 14:56:25 UTC
Cannot reproduce on X11. Are you on Wayland?
Comment 2 aidas957 2024-03-14 18:57:28 UTC
(In reply to Fushan Wen from comment #1)
> Cannot reproduce on X11. Are you on Wayland?

I did mention Wayland in my issue report so definitely yes
Comment 3 xqr 2024-03-17 12:05:57 UTC
I have this issue too, similar configuration, by following the steps I was able to get VRAM to jump from < 1gb to 2.5gb and RAM from ~300mb to 750mb (Though while trying to figure out the source I had it at 1gb+ before). Disabling hover thumbnail also prevents the leak for me.

Integrated Radeon GPU on AMD 7 Pro 5850U 
Linux: 6.7.9-arch1-1
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Wayland Version: 1.22.0-1
Mesa Version: 24.0.3
Comment 4 Michał Lubas 2024-03-20 01:58:57 UTC
FWIW, I have two GPUs - RX570 (amdgpu) and 12900k integrated (i915), with one monitor connected to each gpu. When I start switching between konsole windows when both are present on the monitor connected to the amd gpu, the VRAM is not rising. But when I move both konsole windows to the monitor connected to the Intel gpu and start swithing windows then VRAM (on the *amdgpu* and also system RAM/GTT after a while) is rising rapidly. Disabling thumbnails indeed fixes the issue, thank you for the workaround.
Comment 5 vindicator 2024-04-21 20:12:19 UTC
I'm also encountering a memory leak when hovering over the applications in the status bar (not VRAM though).
X11 (but probably wayland as well since I switched back to X11 after another unusable wayland issue).

I'll be attaching screencaps of heaptrack's "Consumed" and "Top-Down" tabs.

You'll notice the few areas in the chart where I intentionally hovered over each active application in the status bar back and forth several times, along with my time away from my computer (where there was no change).

Is the thumbnail/preview being created and not cached or disposed of every time? Just cache it once for a given PID and dispose of it when the process terminates.

My undesirable workaround for plasmashell as a whole is just to have it die by using "MemoryMax=600M" for the service, where it then just respawns fresh (though open applications in the statusbar may get rearranged each time).
I used that for wayland too, but it was happening much more frequently (more than once a day vs probably a week+ on X11 before it dies), and it was worse for wayland because yesterday before I switched, plasmashell was stuck in a dying state and there were 2 processes open for it. I had to SIGKILL the earlier one.
Comment 6 vindicator 2024-04-21 20:13:36 UTC
Created attachment 168763 [details]
Heaptrack Consumed
Comment 7 vindicator 2024-04-21 20:14:06 UTC
Created attachment 168764 [details]
Heaptrack Top-Down