Bug 508412 - Memory Leak in plasmashell - with heaptrack data.
Summary: Memory Leak in plasmashell - with heaptrack data.
Status: RESOLVED WORKSFORME
Alias: None
Product: plasmashell
Classification: Plasma
Component: generic-performance (other bugs)
Version First Reported In: 6.3.6
Platform: Other Linux
: HI normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: efficiency-and-performance
Depends on:
Blocks:
 
Reported: 2025-08-18 08:11 UTC by Andy
Modified: 2025-10-01 03:46 UTC (History)
5 users (show)

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


Attachments
Configuration file with issue (6.80 KB, text/plain)
2025-08-28 15:52 UTC, boite.pour.spam
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy 2025-08-18 08:11:58 UTC
SUMMARY
There are numerous reports of memory leaks in plasmashell, but few have enough details to actually enable efficient troubleshooting.  I hope to provide all of the info for us to be able to get to the bottom of this.

I'm running debian trixie.  The exact package versions I'm using can be found in the DATA section, below.

STEPS TO REPRODUCE
1. run `htop`.  Observe that plasmashell is using less than 700MB of RES Ram.
2.  Run kde for 6 hours
3.  Observe that for most of this, plasmashell is using 100% CPU.
2. Observe that plasmashell is using more than 2G of RES Ram.  If left alone, it will keep eating ram until the system runs out.

EXPECTED RESULT
No memory leak.  Stable performance

POSSIBLE CONFOUNDING FACTOR
This may or may not be related to an error I got when trying to add a shortcut to the shortcuts settings.  When I tried to add the shortcut I got a "Error while communicating with the global shortcuts service" with these lines in my system log:

2025-08-18T11:07:07.722037+08:00 localhost org.kde.ActivityManager[311980]: org.kde.kactivities.resources: "INSERT INTO ResourceEvent        (usedActivity,  initiatingAgent,  targettedResource,  start,  end) VALUES (:usedActivity, :initiatingAgent, :targettedResource, :start, :end)"
2025-08-18T11:07:07.722383+08:00 localhost org.kde.ActivityManager[311980]: org.kde.kactivities.resources: QSqlError("5", "Unable to fetch row", "database is locked")
2025-08-18T11:07:09.771753+08:00 localhost org.kde.ActivityManager[311980]: org.kde.kactivities.resources: "UPDATE ResourceScoreCache SET cachedScore = :cachedScore, lastUpdate  = :lastUpdate WHERE :usedActivity      = usedActivity AND :initiatingAgent   = initiatingAgent AND :targettedResource = targettedResource "
2025-08-18T11:07:09.771850+08:00 localhost org.kde.ActivityManager[311980]: org.kde.kactivities.resources: QSqlError("5", "Unable to fetch row", "database is locked")
2025-08-18T11:07:10.330716+08:00 localhost systemsettings[357445]: org.kde.kcm_keys: "Error while calling objectPath of added applicationnet.local.screenDim.desktop"
2025-08-18T11:07:10.330952+08:00 localhost systemsettings[357445]: org.kde.kcm_keys: "org.kde.kglobalaccel.NoSuchComponent" "The component 'net.local.screenDim.desktop' doesn't exist."

After that, kglobalacceld slowly started increasing it's RES memory size as well, up to nearly 1GB.  It'll do more if I leave it longer.  I'm not sure if these are two separate issues or if the problem is related to the interaction between the two components.  

DATA:
I'm attaching the packages I have installed and the heaptrack dumps and heaptrack_print analysis for both plasmashell and kglobalacceld here with the hope they will be useful in tracking down the issue(s):  https://drive.google.com/drive/u/0/folders/1dMye3iIzLqhckoXydLYyQ4-cSzbbLeAL

REQUEST:
I'd specifically like to avoid the typical "try this and see if it works" back and forth.  That ends up being very time consuming for both of us in the end, and since a single experiment is 6-12h long, exasperating.  Maybe that's why this specific bug hasn't been fixed yet.  I think a better approach is to focus on how I can either run a single command on my machine that gives you all of the information you need to find the exact line of code that is at fault or how I can get you a suitable replication of my setup so you can reproduce the issue yourself and troubleshoot without me in the loop.  If this heaptrack isn't precisely what you need, then what commands would you like me to run that would give you 99% certainty that you will have what you need to pinpoint the issue in one go?
Comment 1 Bug Janitor Service 2025-08-18 08:33:38 UTC
Thank you for the bug report!

However Plasma 6.3.6 no longer receives updates or maintenance from KDE; active versions are 6.4 or newer. Please upgrade to an active version as soon as your distribution makes it available to you. Plasma is a fast-moving project, and bugs in one version are often fixed in the next one.

If you need help with Plasma 6.3.6, please contact your distribution, who bears the responsibility of providing help for older releases that are no longer receiving updates from KDE.

If you can reproduce the issue after upgrading to an active version, feel free to re-open this bug report.
Comment 2 Andy 2025-08-18 08:51:37 UTC
(In reply to Bug Janitor Service from comment #1)
> Thank you for the bug report!
> 
> However Plasma 6.3.6 no longer receives updates or maintenance from KDE;
> active versions are 6.4 or newer. Please upgrade to an active version as
> soon as your distribution makes it available to you. Plasma is a fast-moving
> project, and bugs in one version are often fixed in the next one.
> 
> If you need help with Plasma 6.3.6, please contact your distribution, who
> bears the responsibility of providing help for older releases that are no
> longer receiving updates from KDE.
> 
> If you can reproduce the issue after upgrading to an active version, feel
> free to re-open this bug report.

Debian Trixie was literally JUST released as stable.  I hope KDE isn't "out of support" before it's marked stable.  That would be a pretty ridiculous situation indeed.
Comment 3 Andy 2025-08-18 09:08:54 UTC
If the KDE in "stable" version of debian is broken, I'd hate to try the "testing" version.  Seems like it would be even more broken.  Anyway, I provided all the info someone should need to find the exact line of code causing the issue.  Once the issue is found, if that same code is in the latest KDE then we still have an issue.  I hope someone will take the time to check as I spent my whole day gathering data for this effort.
Comment 4 Harald Sitter 2025-08-18 14:31:24 UTC
> Debian Trixie was literally JUST released as stable. 

Alas, you need to talk to debian about shipping outdated software then.
Comment 5 David Edmundson 2025-08-18 14:52:36 UTC
>.  I hope someone will take the time to check as I spent my whole day gathering data for this effort.

Just to be clear, it is appreciated and we'll look through it. 
Any frustrating about software versions is aimed at Debian not you.
Comment 6 David Edmundson 2025-08-18 15:01:48 UTC
From the trace, we're in the code that reads through $XDG_DATA_DIRS/share/applications . That code hasn't been changed in years, so we're probably hitting an unusual case rather than it being a regression.

The code ksycoca uses is based on timestamps of when we last indexed and the last updates in the relevant folders. I strongly suspect one of these folders /usr/share/applications .local/share/applications  etc.  has a timestamp in the future.

Output of 
QT_LOGGING_RULES=kf.service.services.debug=true plasmashell --replace

when we're going haywire would be the most helpful.
Comment 7 Andy 2025-08-19 03:01:10 UTC
(In reply to David Edmundson from comment #6)
> From the trace, we're in the code that reads through
> $XDG_DATA_DIRS/share/applications . That code hasn't been changed in years,
> so we're probably hitting an unusual case rather than it being a regression.
> 
> The code ksycoca uses is based on timestamps of when we last indexed and the
> last updates in the relevant folders. I strongly suspect one of these
> folders /usr/share/applications .local/share/applications  etc.  has a
> timestamp in the future.
> 
> Output of 
> QT_LOGGING_RULES=kf.service.services.debug=true plasmashell --replace
> 
> when we're going haywire would be the most helpful.

Thank you for looking into this.  Yeah I get your frustration about trying to make progress on KDE while being pressured to support versions that are 2-3 years old, and how difficult it must be to try and keep that much code in your head at once.  I think everyone wants a good user experience and your strategy (have everyone use the latest version) and their strategy (have everyone use the version that has had the longest time to be debugged and fixed) just aren't aligning.  Anyway it's much bigger than you and me.  Thank you for your help.

Here is some data about your hunch:
    
```
[<usernameRedacted>@<hostRedacted> tmp]$ echo "$XDG_DATA_DIRS" 
/usr/share/xfce4:/usr/share/gnome:/home/<usernameRedacted>/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
[<usernameRedacted>@<hostRedacted> tmp]$ sudo su
[root@<hostRedacted> tmp]$ find /usr/share/xfce4 /usr/share/gnome /home/<usernameRedacted>/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /usr/local/share /usr/share -type d -newerct now
find: ‘/home/<usernameRedacted>/.local/share/flatpak/exports/share’: No such file or directory
[root@<hostRedacted> tmp]$ find /usr/share/xfce4 /usr/share/gnome /home/<usernameRedacted>/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /usr/local/share /usr/share -type d -newermt now
find: ‘/home/<usernameRedacted>/.local/share/flatpak/exports/share’: No such file or directory
[root@<hostRedacted> tmp]$ find /usr/share/xfce4 /usr/share/gnome /home/<usernameRedacted>/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /usr/local/share /usr/share -type d -newerat now
find: ‘/home/<usernameRedacted>/.local/share/flatpak/exports/share’: No such file or directory
```

I redacted some parts for privacy.

Besides one folder in the $XDG_DATA_DIRS no longer existing, `find` could not find any files with create, modify, or access in the future.

Because of the pain of running out of memory every few hours, I've switched to xfce temporarily.  I'll try to run the command you requested next time I log in fresh.  I do prefer KDE so I hope we can get to the bottom of this together.

What is the minimum file set that interacts with the relevant code.  Can tar.gz some directories that will allow you to reproduce this on your end and hasten our dev feedback loop?  Right now it's gonna be about a 24-48h loop because of time zone differences.  As a developer myself I've learned that the faster the loop is, the more effective we are.
Comment 8 Andy 2025-08-19 03:06:59 UTC
Here is the output you requested: 

```[<userRedacted>@<hostRedacted> ~]$ QT_LOGGING_RULES=kf.service.services.debug=true plasmashell --replace
kf.plasma.core: Applet invalid: Cannot find a package for "org.kde.plasma.systemloadviewer"
kf.plasma.quick: Applet preload policy set to 1
kf.service.services: query for mimeType "application/octet-stream" returning 0 offers
kf.service.services: query for mimeType "application/octet-stream" returning 0 offers
file:///usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:178:25: QML FolderViewDropArea (parent or ancestor of QQuickLayoutAttached): Binding loop detected for property "minimumWidth":
file:///usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:201:9
Toolbox not loading, toolbox package is either invalid or disabled.
file:///usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:178:25: QML FolderViewDropArea (parent or ancestor of QQuickLayoutAttached): Binding loop detected for property "minimumWidth":
file:///usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:201:9
Toolbox not loading, toolbox package is either invalid or disabled.
kf.service.services: query returning 0 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 1 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 1 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 1 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query for mimeType "x-scheme-handler/http" returning 7 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 0 offers
kf.service.services: query returning 1 offers
<repeats the last 9 lines about once every second>```
Comment 9 boite.pour.spam 2025-08-28 10:18:14 UTC Comment hidden (spam)
Comment 10 boite.pour.spam 2025-08-28 11:47:31 UTC Comment hidden (spam)
Comment 11 boite.pour.spam 2025-08-28 11:58:44 UTC Comment hidden (spam)
Comment 12 boite.pour.spam 2025-08-28 15:48:12 UTC
Ok, I think I've found the culprit (but nuked my plasma customization meanwhile).

As soon as you add a "org.kde.plasma.kickerdash" widget to the menu bar, plasmashell starts consuming CPU like a crazy dog. It's completely lazy with "org.kde.plasma.kickoff" (less than 1% CPU) but explode to 100% with kickerdash (which is called something like "Application panel board" / "Tableau de bord des applications").

There's something very wrong with this widget in the last versions, and I don't know why.
Comment 13 boite.pour.spam 2025-08-28 15:52:12 UTC Comment hidden (spam)
Comment 14 Andy 2025-08-29 10:52:08 UTC
Hi boiite,  

Thanks for trying to move this ball down the field a bit.  I'm afraid we may be seeing two different issues with similar symptoms, as I do not use the kickerdash widget.  Between my heaptrack and your strace, I feel like a KDE developer could solve this in a day if we could just get someones attention....

I'm having to choose between debugging someone else's code, or spending a day of my time reverting my system to a version of debian that is going to be EOL in a year.  One really shouldn't have to do that.  "Stable" should mean stable!  :(  It breaks trust to ship something that is broken, especially when it worked before!

Andy
Comment 15 David Edmundson 2025-08-29 14:51:43 UTC Comment hidden (spam)
Comment 16 David Edmundson 2025-08-29 15:02:22 UTC
Edit. We had a different bug about kickerdash (that only affects master). I might have been too quick to comment.

If your symptoms match it could well be the same thing.

The original traces from Andy do show it's libkicker calling into kworkspace / DefaultService::browser in a crazy loop.
That plugin is shared with kickerdash.
Comment 17 David Edmundson 2025-08-29 15:10:39 UTC
If you have the time, can either of you run with:

> QT_LOGGING_RULES=kf.service.sycoca.debug=true plasmashell --replace

when in the broken state and can you also can you include 

ls -lh ~/.cache/ksycoca6-*
Comment 18 Andy 2025-08-31 12:52:20 UTC
I'm sorry I won't be of any help any longer.  I couldn't stand to use debian trixie with this plasma memory leak and blutooth glitches.  I tried switching to xfce but it just didn't feel right, so I spent the last 2 days reverting to bookworm.  It's a sad thing to do, but I had to think of my productivity and I wasn't confident this was going to be fixed soon enough.  I'll need to upgrade again when bookworm goes End of Life, so I hope things will be fixed by then.  Good luck!
Comment 19 boite.pour.spam 2025-08-31 12:59:53 UTC
(In reply to David Edmundson from comment #17)
> If you have the time, can either of you run with:
> 
> > QT_LOGGING_RULES=kf.service.sycoca.debug=true plasmashell --replace
> 
> when in the broken state and can you also can you include 
> 
> ls -lh ~/.cache/ksycoca6-*

I'll come back to you on monday.
Comment 20 boite.pour.spam 2025-09-01 10:02:24 UTC
I'm not able to reproduce the issue I had. I've reverted my system back to Plasma 6.3 (I prefer to stay on Manjaro "Stable"). I've removed many applications I don't use anymore (because going from Stable to Unstable broke them or vice versa). 

In the end, I've rebooted a number of time and plasmashell doesn't eat CPU like it did last Friday.
Comment 21 David Edmundson 2025-09-01 21:55:05 UTC
Ok, thanks for the feedback both of you. I'll keep an eye out for similar reports and will have a headstart on getting that in the right direction.
Comment 22 Bug Janitor Service 2025-09-16 03:48:02 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 23 Bug Janitor Service 2025-10-01 03:46:39 UTC
🐛🧹 This bug has been in NEEDSINFO status with no change for at least 30 days. Closing as RESOLVED WORKSFORME.