Bug 403563 - Memory leak in plasma desktop (plasmashell)
Summary: Memory leak in plasma desktop (plasmashell)
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: generic-performance (show other bugs)
Version: 5.14.4
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-24 17:52 UTC by Matthew Woehlke
Modified: 2023-06-10 11:01 UTC (History)
15 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kwin info (5.87 KB, text/plain)
2019-01-25 16:31 UTC, Matthew Woehlke
Details
plasmarc (21 bytes, text/plain)
2019-02-20 19:04 UTC, Matthew Woehlke
Details
plasmashellrc (2.25 KB, text/plain)
2019-02-20 19:04 UTC, Matthew Woehlke
Details
plasma-org.kde.plasma.desktop-appletsrc (10.80 KB, text/plain)
2019-02-20 19:05 UTC, Matthew Woehlke
Details
Settings an KWin support info (4.96 KB, application/gzip)
2023-05-23 20:27 UTC, Jonathan Wakely
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Woehlke 2019-01-24 17:52:07 UTC
SUMMARY
There is a memory leak in plasma that causes it to eventually consume an unbounded quantity of memory, resulting in system slowness / potential instability.

STEPS TO REPRODUCE
1. Run plasmashell (i.e. "the KDE desktop")
2. Use the computer for several days

OBSERVED RESULT
The plasmashell process is consuming many GB of memory (16GB, 32GB, more...) and is >45% RES.

EXPECTED RESULT
Memory usage is relatively low and stable.

SOFTWARE/OS VERSIONS
bash-4.4.23-5.fc29.x86_64
coreutils-8.30-6.fc29.x86_64
dbus-x11-1.12.10-1.fc29.x86_64
glibc-2.28-26.fc29.x86_64
iso-codes-3.79-2.fc29.noarch
kactivitymanagerd-5.14.4-1.fc29.x86_64
kde-settings-plasma-29.0-1.fc29.noarch
kf5-attica-5.53.0-1.fc29.x86_64
kf5-baloo-5.53.0-1.fc29.x86_64
kf5-baloo-libs-5.53.0-1.fc29.x86_64
kf5-filesystem-5.53.0-1.fc29.x86_64
kf5-frameworkintegration-5.53.0-3.fc29.x86_64
kf5-kactivities-5.53.0-1.fc29.x86_64
kf5-kauth-5.53.0-1.fc29.x86_64
kf5-kbookmarks-5.53.0-1.fc29.x86_64
kf5-kcodecs-5.53.0-1.fc29.x86_64
kf5-kcompletion-5.53.0-1.fc29.x86_64
kf5-kconfig-core-5.53.0-1.fc29.x86_64
kf5-kconfig-gui-5.53.0-1.fc29.x86_64
kf5-kconfigwidgets-5.53.0-1.fc29.x86_64
kf5-kcoreaddons-5.53.0-1.fc29.x86_64
kf5-kcrash-5.53.0-1.fc29.x86_64
kf5-kdbusaddons-5.53.0-1.fc29.x86_64
kf5-kdeclarative-5.53.0-3.fc29.x86_64
kf5-kded-5.53.0-1.fc29.x86_64
kf5-kdelibs4support-libs-5.53.0-1.fc29.x86_64
kf5-kdoctools-5.53.0-1.fc29.x86_64
kf5-kfilemetadata-5.53.0-1.fc29.x86_64
kf5-kglobalaccel-5.53.0-1.fc29.x86_64
kf5-kglobalaccel-libs-5.53.0-1.fc29.x86_64
kf5-kguiaddons-5.53.0-1.fc29.x86_64
kf5-ki18n-5.53.0-1.fc29.x86_64
kf5-kiconthemes-5.53.0-1.fc29.x86_64
kf5-kinit-5.53.0-1.fc29.x86_64
kf5-kio-core-libs-5.53.0-1.fc29.x86_64
kf5-kio-file-widgets-5.53.0-1.fc29.x86_64
kf5-kio-widgets-libs-5.53.0-1.fc29.x86_64
kf5-kitemmodels-5.53.0-1.fc29.x86_64
kf5-kitemviews-5.53.0-1.fc29.x86_64
kf5-kjobwidgets-5.53.0-1.fc29.x86_64
kf5-knewstuff-5.53.0-1.fc29.x86_64
kf5-knotifications-5.53.0-1.fc29.x86_64
kf5-kpackage-5.53.0-1.fc29.x86_64
kf5-kparts-5.53.0-1.fc29.x86_64
kf5-krunner-5.53.0-1.fc29.x86_64
kf5-kservice-5.53.0-1.fc29.x86_64
kf5-ktexteditor-5.53.0-1.fc29.x86_64
kf5-ktextwidgets-5.53.0-1.fc29.x86_64
kf5-kunitconversion-5.53.0-1.fc29.x86_64
kf5-kwayland-5.53.0-3.fc29.x86_64
kf5-kwidgetsaddons-5.53.0-1.fc29.x86_64
kf5-kwindowsystem-5.53.0-1.fc29.x86_64
kf5-kxmlgui-5.53.0-3.fc29.x86_64
kf5-kxmlrpcclient-5.53.0-1.fc29.x86_64
kf5-plasma-5.53.0-1.fc29.x86_64
kf5-prison-5.53.0-1.fc29.x86_64
kf5-solid-5.53.0-1.fc29.x86_64
kf5-sonnet-ui-5.53.0-1.fc29.x86_64
khotkeys-5.14.4-2.fc29.x86_64
kscreenlocker-5.14.4-1.fc29.x86_64
ksysguardd-5.14.4-1.fc29.x86_64
libICE-1.0.9-14.fc29.x86_64
libSM-1.2.3-1.fc29.x86_64
libX11-1.6.7-1.fc29.x86_64
libXext-1.3.3-10.fc29.x86_64
libXrender-0.9.10-8.fc29.x86_64
libXtst-1.2.3-8.fc29.x86_64
libgcc-8.2.1-6.fc29.x86_64
libksysguard-5.14.4-1.fc29.x86_64
libkworkspace5-5.14.4-1.fc29.x86_64
libstdc++-8.2.1-6.fc29.x86_64
libxcb-1.13.1-1.fc29.x86_64
oxygen-sound-theme-5.14.4-1.fc29.noarch
phonon-qt5-4.10.1-2.fc29.x86_64
plasma-desktop-5.14.4-2.fc29.x86_64
plasma-lookandfeel-fedora-5.14.4-1.fc29.noarch
plasma-milou-5.14.4-1.fc29.x86_64
plasma-pa-5.14.4-1.fc29.x86_64
plasma-workspace-5.14.4-1.fc29.x86_64
plasma-workspace-common-5.14.4-1.fc29.x86_64
plasma-workspace-libs-5.14.4-1.fc29.x86_64
polkit-kde-5.14.4-1.fc29.x86_64
powerdevil-5.14.4-1.fc29.x86_64
qt5-qtbase-5.11.3-1.fc29.x86_64
qt5-qtbase-gui-5.11.3-1.fc29.x86_64
qt5-qtdeclarative-5.11.3-1.fc29.x86_64
qt5-qtgraphicaleffects-5.11.3-1.fc29.x86_64
qt5-qtquickcontrols-5.11.3-1.fc29.x86_64
qt5-qttools-5.11.3-1.fc29.x86_64
qt5-qtx11extras-5.11.3-1.fc29.x86_64
socat-1.7.3.2-7.fc29.x86_64
systemd-239-8.gite339eae.fc29.x86_64
xcb-util-0.4.0-11.fc29.x86_64
xcb-util-image-0.4.0-11.fc29.x86_64
xorg-x11-apps-7.7-22.fc29.x86_64
xorg-x11-server-utils-7.7-26.fc29.x86_64
xorg-x11-utils-7.5-29.fc29.x86_64
zlib-1.2.11-14.fc29.x86_64

ADDITIONAL INFORMATION
I'm using slideshow wallpaper on a 5 minute rotation, 2.5 screens (one "screen" is 1080p entirely within the bounds of a 1920x1200, but I've noticed plasma sometimes seems to use it as a separate screen).

This seems like #368838 again, but is still happening despite that bug supposedly being "fixed". (Note: I was advised on that bug to open a new report.)
Comment 1 David Edmundson 2019-01-24 22:09:09 UTC
>Note: I was advised on that bug to open a new report.

Yes, thanks. 

I'm afraid I'm going to need a lot of info to narrow this down.

1) Does it mostly go away if you don't have a slideshow wallpaper?

2) Can I have the output of:
qdbus org.kde.KWin /KWin org.kde.KWin.supportInformation  

3) If you run "kcmshell5 qtquicksettings" does it go away if you set Render loop is set to "basic" and run "plasmashell --replace"



4) If you run "kcmshell5 qtquicksettings" does it go away if rendering backend is set to "software" and run "plasmashell --replace"
Comment 2 Matthew Woehlke 2019-01-25 16:31:55 UTC
Created attachment 117657 [details]
kwin info

Unfortunately, it's going to be hard to answer "does it go away" questions, since it usually takes at least a few days before the issue becomes apparent. At best, I can try experiments and report back if some weeks pass without issue.

Kwin info is attached.
Comment 3 Matthew Woehlke 2019-02-04 14:53:21 UTC
Okay... after initially making the first change (render loop = basic), it ran fine for a while, then X crashed. This morning, however:

  virt: 15.2G
  res:  11.8G
  shr:   3.8M
  mem:  37.6%
  time: 1h23m

Is it possible there is something different about the instance that's auto-started? I'm not entirely certain but what I may only be seeing problems with the initial auto-started instance...
Comment 4 Matthew Woehlke 2019-02-12 18:19:52 UTC
...and again:
 v: 14.9G
 r: 13.0G
 m: 41%

This was with basic/software.
Comment 5 Christoph Feck 2019-02-15 17:28:27 UTC
Information was provided with comment #2; changing status for inspection.
Comment 6 David Edmundson 2019-02-20 09:21:28 UTC
Can you attach your 

~/.config/plasmarc
~/.config/plasmashellrc
~/.config/plasma-org.kde.plasma.desktop-appletsrc
Comment 7 Matthew Woehlke 2019-02-20 19:04:06 UTC
Created attachment 118227 [details]
plasmarc
Comment 8 Matthew Woehlke 2019-02-20 19:04:25 UTC
Created attachment 118228 [details]
plasmashellrc
Comment 9 Matthew Woehlke 2019-02-20 19:05:16 UTC
Created attachment 118229 [details]
plasma-org.kde.plasma.desktop-appletsrc
Comment 10 Bug Janitor Service 2019-03-07 04:33:07 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 11 Matthew Woehlke 2019-03-08 00:27:24 UTC
Requested information was provided AFAICT.
Comment 12 YAFU 2021-04-18 11:15:56 UTC
Hi. I see that there are many similar reports about Plasmashell Memory Leak problem occurring even to this day.
I don't use slideshow wallpaper. I never power off my PC, I always sleep/suspend to RAM. I can suspend to RAM and resume the PC several times without plasmashell memory leak problem happening, but suddenly sometime when I resume the PC the problem starts to occur and I can notice it when I resume from suspend to RAM and I get a little freeze in Plasma until it does it becomes responsive after a few seconds. So from this point I start to check Plasmashell RAM usage, and from this point the problem after suspending RAM and Resume is always reproducible. From this point every time you suspend to RAM and Resume, plasmashell increases RAM usage up to a lot and plasma becomes slower every time.
I'm not sure how to debug the problem when it occurs in order to provide some useful information.
Comment 13 Quartz 2021-10-21 18:20:05 UTC
Bump x5. 

I'd appreciate if this bug takes priority - it might be causing other accidental threads being created in relation to memory leaks and mistaking side effects in other places (such as I did with plasma widgets).

It makes it impossible to keep a desktop linux distro running KDE for several days and it's making the desktop environment give a really poor impression and experience.
Comment 14 Ruben Kelevra 2022-04-15 13:06:45 UTC
Soooo ... is this going to be fixed or does your users have to change to another DE?

I mean it's 3 years now and I still get memory leaks on a daily basis (with a sliding desktop wallpaper - not sure why this memory leak issue isn't fixed after 8 years...)
Comment 15 Mathis DELGADO 2022-06-29 18:26:12 UTC
Will ever this bug will be fixed ? It is really annoying when you have to restart your computer several times a day because plasmashell has a huge memory leak... Isn't is possible to mark this bug as important, not as "normal" priority ? It litterally ruins the user experience.

I personnally don't use the slideshow background but I have these memory leaks anyways.
Comment 16 Raman Gupta 2022-10-24 15:43:22 UTC
This is the issue that comes up when Googling "plasmashell memory leak", so I'll post here. There are usually multiple root causes of these types of problems, but without better ways to debug / investigate these issues than "try it with this configuration" it is really hard for users to determine whether we are talking about the same issue or not.

On my Fedora 36 system with 128 GB of real memory, systemd-oomd has killed plasmashell twice in two days for using almost 133 GB of memory (real memory + considerable swap). There is no conceivable situation in which plasmashell should be using that much memory.

Oct 23 03:04:40 edison systemd-oomd[1888]: Killed /user.slice/user-1000.slice/user@1000.service/session.slice/plasma-plasmashell.service due to memory used (132956889088) / total (134229807104) and swap used (27105050624) / total (30064758784) being more than 90.00%
Oct 23 03:04:40 edison systemd[2255]: plasma-plasmashell.service: systemd-oomd killed 199 process(es) in this unit.

and then almost exactly 24 hours later:

Oct 24 03:05:46 edison systemd-oomd[1888]: Killed /user.slice/user-1000.slice/user@1000.service/session.slice/plasma-plasmashell.service due to memory used (132685852672) / total (134229807104) and swap used (27061297152) / total (30064758784) being more than 90.00%
Oct 24 03:05:46 edison systemd[2255]: plasma-plasmashell.service: systemd-oomd killed 156 process(es) in this unit.

I do find it suspicious that both instances happened at almost exactly the same time overnight -- the cron log does not show any process triggering at or around that time.

If there is a way to effectively debug this sort of thing, that would be helpful.

I don't use slideshow wallpaper.

Output of qdbus supportInformation: https://invent.kde.org/-/snippets/2387
Comment 17 Jonathan Wakely 2023-05-23 20:27:13 UTC
Created attachment 159213 [details]
Settings an KWin support info

For the past few weeks plasmashell (version plasma-workspace-x11-5.27.4.1-1.fc37.x86_64 from fedora RPMs) has been growing to tens of gigabytes while idle and getting killed by the oomkiller. I've attached my ~/config/plasma*rc and the kwin support info as requested above.

I've tried setting the Render loop to basic and will see if that changes anything.
Comment 18 Jonathan Wakely 2023-05-23 23:32:04 UTC
Well that didn't help:

top - 00:29:30 up  8:52,  6 users,  load average: 3.24, 2.35, 2.20
Tasks: 412 total,   2 running, 410 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.9 us,  7.7 sy,  0.0 ni, 26.6 id, 63.3 wa,  0.3 hi,  0.3 si,  0.0 st
MiB Mem :  64229.3 total,    380.3 free,  63408.5 used,    440.5 buff/cache
MiB Swap:  69618.0 total,  22149.9 free,  47468.1 used.    141.8 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                              
     76 root      20   0       0      0      0 R  38.5   0.0  22:44.61 kswapd0                                                                              
 114347 root      20   0   25.4g  39608  25700 S   7.6   0.1   1:32.63 Xorg                                                                                 
 114631 jwakely   20   0 1515740  20804  15968 S   2.7   0.0   0:04.83 kded5                                                                                
   3092 jwakely    9 -11  473512  12616   8144 S   2.3   0.0   0:02.24 wireplumber                                                                          
 114634 jwakely   20   0 1323284  53276  44564 D   2.3   0.1   1:02.43 kwin_x11                                                                             
 115789 jwakely   20   0 3071832  86556  30860 S   2.0   0.1   3:54.37 Isolated Web Co                                                                      
 115756 jwakely   20   0 3063488  87384  30896 S   1.7   0.1   3:52.92 Isolated Web Co                                                                      
 118895 jwakely   20   0  100.4g  54.9g  33756 D   1.7  87.5  30:56.40 plasmashell           


It's about 4 hours since I restarted plasmashell (then left the system idle), and it's reached 100gb and the system is performing badly due to swapping.

I'll try software rendering tomorrow.
Comment 19 Jonathan Wakely 2023-05-24 19:44:17 UTC
> I'll try software rendering tomorrow.

That didn't make any difference. The last time I had the problem the plasmashell process grew to 78gb in about 20 minutes.

But I've noticed that when I turn off my display and watch plasmashell using `top` in an ssh session on another machine, it spikes to 100% CPU usage every 15-20 seconds. When the display is on, that doesn't happen, it stays at about 0% all the time. This observation seems correlated to the fact that the memory leaks happen when I'm away from the machine and it's idle, because I always turn the screen off when I leave the desk.
Comment 20 Jonathan Wakely 2023-05-24 19:59:33 UTC
    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                              
  22860 jwakely   20   0 2048664 399404 187656 S  96.3   0.6   0:32.10 QSGRenderThread                                                                      
   3222 jwakely   20   0 2048664 399404 187656 S   0.3   0.6   0:07.03 plasmashell                                                                          
   3238 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.17 QDBusConnection                                                                      
   3239 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.51 QXcbEventQueue                                                                       
   3352 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.31 QQmlThread                                                                           
   3363 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.31 Qt bearer threa                                                                      
   3508 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:01.50 QQuickPixmapRea                                                                      
   3577 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.00 CPMMListener                                                                         
   3588 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.07 plasmashell                                                                          
   3728 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.00 KCupsConnection                                                                      
   4218 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.65 QSGRenderThread                                                                      
   8537 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.34 QSGRenderThread                                                                      
  21405 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.05 QSGRenderThread                                                                      
  21413 jwakely   20   0 2048664 399404 187656 S   0.0   0.6   0:00.38 QSGRenderThread     

That thread is running code from the nvidia drivers, so maybe that's where the problem is:

Thread 14 (Thread 0x7fdd7d5ba6c0 (LWP 22860) "QSGRenderThread"):
#0  0x00007fddcc52221f in __GI___poll (fds=0x7fdd7d5b95b8, nfds=1, timeout=1000) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fddb2912a50 in  () at /lib64/libnvidia-glcore.so.530.41.03
#2  0x00007fddb29c3e51 in  () at /lib64/libnvidia-glcore.so.530.41.03
#3  0x00007fddb9aefe1c in  () at /lib64/libGLX_nvidia.so.0
#4  0x00007fddb9abfe30 in  () at /lib64/libGLX_nvidia.so.0
#5  0x00007fddc874fe21 in QGLXContext::swapBuffers(QPlatformSurface*) (this=0x7fdd582c79d0, surface=0x55b4cb438680) at qglxintegration.cpp:637
#6  0x00007fddcea479db in QSGRenderThread::syncAndRender(QImage*) (this=this@entry=0x55b4cd1bc1c0, grabImage=grabImage@entry=0x0) at scenegraph/qsgthreadedrenderloop.cpp:869
#7  0x00007fddcea480eb in QSGRenderThread::run() (this=0x55b4cd1bc1c0) at scenegraph/qsgthreadedrenderloop.cpp:1042
#8  0x00007fddccae855b in operator() (__closure=<optimized out>) at thread/qthread_unix.cpp:350
#9  (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::<lambda()> > (t=<optimized out>) at thread/qthread_unix.cpp:287
#10 QThreadPrivate::start(void*) (arg=0x55b4cd1bc1c0) at thread/qthread_unix.cpp:310
#11 0x00007fddcc4ae12d in start_thread (arg=<optimized out>) at pthread_create.c:442
#12 0x00007fddcc52fbc0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Comment 21 Szőts Ákos 2023-06-03 15:41:33 UTC
I don't know whether it's related, but Bug 465441 has heaptrack report attached with specific line number causing the leak.
Comment 22 Sebastian 2023-06-10 11:01:32 UTC
(In reply to YAFU from comment #12)
> Hi. I see that there are many similar reports about Plasmashell Memory Leak
> problem occurring even to this day.
> I don't use slideshow wallpaper. I never power off my PC, I always
> sleep/suspend to RAM. I can suspend to RAM and resume the PC several times
> without plasmashell memory leak problem happening, but suddenly sometime
> when I resume the PC the problem starts to occur and I can notice it when I
> resume from suspend to RAM and I get a little freeze in Plasma until it does
> it becomes responsive after a few seconds. So from this point I start to
> check Plasmashell RAM usage, and from this point the problem after
> suspending RAM and Resume is always reproducible. From this point every time
> you suspend to RAM and Resume, plasmashell increases RAM usage up to a lot
> and plasma becomes slower every time.
> I'm not sure how to debug the problem when it occurs in order to provide
> some useful information.

I am having the exact same issue (2 years later...). The leak becomes apparent after about 20 sleep/resume cycles or so, then plasmashell memory consumption increases exponentially each time.

On Ubuntu Studio 22.04, KDE Plasma 5.24.7, X11 with NVidia RTX3060.