SUMMARY My integrated AMD GPU has a substantial amount of memory assigned to GART [1]. In fact, about half my system memory is available for GART. Over about a week of using KDE under Wayland, I see the GART memory use slowly climb. It fluctuates on a minute to minute basis, e.g. if I close Firefox right now I'll probably reclaim 300-500 MB of GART. Since the GART overlaps with system memory my available system memory will also increase by this amount (in addition to reclaimed pages from closing Firefox). However, this savings from closing an application is temporary. With KDE under Wayland, usage slowly but inevitably climbs until it is full (reaches the maximum allocation the kernel will give it). When this happens, graphics heavy effects like the Overview effect will become slow and laggy. It will feel like KDE is slow, or that something is taxing the CPU, or that the system memory is low, but this isn't the case. Even after killing every application on my desktop (even restarting plasmashell), this memory is not reclaimed. We're talking at least 16 GB of memory on my system that can't be used until I end the KDE graphical session. On top of the visible problems (like stuttering) this induces, it can also be a problem for memory availability. STEPS TO REPRODUCE 1. Have an integrated AMDGPU (?) 2. Use KDE for a while (about a week?) without shutting down or closing your session. (Putting the system to sleep is fine.) Some notes on usage: * I have multiple monitors and switch between them regularly. * I occasionally use graphics heavy programs, e.g. video games (and even Firefox can be relatively heavy). These games are still being composited by the KWin compositor for Wayland, which seems like a possible source of this problem. OBSERVED RESULT The memory claimed by GART (check `radeontop` for this, where it is reported as "GTT") slowly climbs until all available resources are consumed. I've noticed that doing anything graphics heavy seems to make the problem worse (even after closing the program), although it's extremely difficult to quantify this since there's plenty of temporary fluctuation. EXPECTED RESULT With no programs running (except the KDE desktop) the memory claimed by graphics should be very low. I would naively say that no more than 1 GB is reasonable, but in any case the usage I'm seeing exceeds that by far. SOFTWARE/OS VERSIONS Operating System: Arch Linux KDE Plasma Version: 5.93.0 KDE Frameworks Version: 5.249.0 Qt Version: 6.7.0 Kernel Version: 6.7.3-arch1-1 (64-bit) Graphics Platform: Wayland ADDITIONAL INFORMATION I'm going to switch to the X11 session for a few days to see if I can replicate the issue there. If I can, I'll try switching to something else (e.g. Gnome?) for the same amount of time, to hopefully verify that this is not a weird issue with my graphics drivers. I don't think it is - ending the KDE session and returning to the getty login clears *all* the claimed memory immediately. [1] https://en.wikipedia.org/wiki/Graphics_address_remapping_table
I'm over 2 days into an X11 session now, and it is *very* clear already that the issue doesn't affect X11. I've played videos, games, used the browser heavily, and so on, and right now (as I type this into the browser) my GPU is using only 461 MB of GART memory. I would greatly appreciate anyone with a recent AMD laptop trying to reproduce this. As things stand, the KDE Wayland session isn't really usable for me unless I shut down my computer every day. It simply uses too much RAM. I expect many others will have this issue too, although it's not the easiest to isolate the cause and these issues might not get reported.
Can you check what exactly triggers kwin to leak memory? maybe toggling overview or task switcher? or does memory continuously leak without doing anything?
I'm switching back to Wayland since I think I can confirm it's specific to that. It tends to slowly grow over time, so it's hard to pinpoint. The biggest thing I've noticed so far is that putting the computer to sleep and waking it up again (and unlocking the lock screen) tends to create a temporary jump, and some of this seems to be "sticky". Unfortunately this is pretty variable. Sometimes no more than 10 MB or so sticks around, sometimes (like right now as I write this comment, as a test), it goes from 350 MB used to 1100 MB used, and even after waiting for it to subside for a few minutes, it's stuck at 800 MB. So that's a 450 MB jump in memory usage by the graphics system in less than a minute. For clarity and emphasis, this didn't happen under the KDE X11 session in my testing. After 2+ days of use, with a browser running, only 461 MB of GART memory was consumed by graphics.
One additional thing I've noticed, which may indicate that suspend is a red herring here: If you fill up both the entire VRAM (1 GB) and some amount of GART (e.g. 1 GB) - I did this by running several games at once - and then suspend the system while the games are still running, when the system is resumed the VRAM value will be <= 100 MB and GART will have increased by the difference. The exact significance of this isn't clear to me, but it may indicate that the KDE leak is happening in VRAM. I think I need to be tracking both the VRAM and GART usage - probably a sustained increase in the sum of the two reflects a leak.
I haven't seen this happen on my AMD laptop. Can you still reproduce this with the released Plasma 6?
I haven't see the issue recur, so I'm going to close this for now. I'll reopen this if it happens again. Some notes for others who may have encountered similar issues: * The issue began for me either after Plasma 6 beta 1 or beta 2 was installed. It was clearly present continuously for some time - even before I diagnosed the issue, any time Plasma had been running for more than a few days I would encounter performance issues. * The Plasma 6 Wayland session still uses quite a bit more graphics memory than Xorg, and this amount grows over time. Recently (since I stopped being able to reproduce the bug), I see 2-3 GB of graphics memory held under Wayland after about a week of use, vs ~0.5 GB for Xorg. But I haven't seen 50+% utilization of GART since I reported the issue. * The way you'd confirm you have the issue on an AMD system is, (a) you see a lot of memory use that is not attributable to applications, cache, or ZFS ARC, (b) the memory is not automatically reclaimed when you start an application that uses a lot of memory - it crashes or you get an OOM condition, and (c) running `radeontop` shows 90+% utilization of "GTT" memory, (d) closing all userspace applications doesn't reduce it significantly, and (e) closing your Plasma session and returning to a VTERM immediately reduces GART / GTT usage to ~0%.