High Memory Usage from Plasmashell. Is it a memory leak?

I may have found a memory with plasmashell but I want to make sure before I decide to post a bug report.

Severity: One time, my device memory usage was extremely high even though I had only firefox open with 5 tabs (3-4 inactive tabs), then my device restarted automatically and I think it’s because the memory usage reached the maximum memory on the device (16GB). Hence why I want to fix this issue so it doesn’t happen again.

  • When I start my machine, plasmashell uses about 300MB (normal). But after a few days, I noticed it goes up to 3GB and it could possibly go higher.
  • I used valgrind --leak-check=full --show-leak-kinds=all --log-file='valgrind_logs_plasmashell.txt' plasmashell to see if there were memory leaks and there were +100,000 lines in the log file. Here is the summary:
==12105== LEAK SUMMARY:
==12105==    definitely lost: 280 bytes in 2 blocks
==12105==    indirectly lost: 2,542 bytes in 24 blocks
==12105==      possibly lost: 1,440 bytes in 5 blocks
==12105==    still reachable: 887,892 bytes in 8,067 blocks
==12105==                       of which reachable via heuristic:
==12105==                         newarray           : 3,344 bytes in 22 blocks
==12105==         suppressed: 0 bytes in 0 blocks
==12105== 
==12105== For lists of detected and suppressed errors, rerun with: -s
==12105== ERROR SUMMARY: 14 errors from 14 contexts (suppressed: 0 from 0)

Debugging Plasmashell:

  • I followed the instructions in: [Plasma/Debugging - KDE Community Wiki]
  • I found that clicking on the default widgets (for me it is Volume, Bluetooth, Wifi, Battery and Calendar) to open the pop-up window and then clicking on it again to close it, increases the memory usage a bit. This log also appeared whenever I did it: The cached device pixel ratio value was stale on window update. Please file a QTBUG which explains how to reproduce.
  • I repeatedly kept doing it (constantly clicking on the widgets to open and close the pop-up windows), the same log appeared and the memory usage kept on increasing (went from 17.2% to 17.6%).
  • Then eventually the pop-up window stopped appearing when I clicked on the widgets and this log started appearing instead of the previous one: qt.qpa.wayland: eglSwapBuffers failed with 0x3000, surface: 0x637b10f00d20. This same log appeared when I clicked on all the widgets that I mentioned earlier and their pop-up windows did not appear at all.
  • After waiting a while, I did it again and the pop-up window did appear but when I clicked the widget again to close the window, the panel disappeared (like it got hidden) and then these logs started appearing:
Feb 01 04:17:37 my_device plasmashell[1094]: The Wayland connection experienced a fatal error: Too many open files
Feb 01 04:17:38 my_device plasmashell[180735]: KPackageStructure of KPluginMetaData(pluginId:"org.kde.plasma.kclock_1x2", fileName: "/usr/share/plasma/plasmoids/org.kde.plasma.kclock_1x2/metadata.json") does not match requested format "Plasma/Applet"
Feb 01 04:17:38 my_device plasmashell[180735]: kf.plasma.quick: Applet preload policy set to 1
Feb 01 04:17:38 my_device plasmashell[180735]: qml: false
Feb 01 04:17:38 my_device plasmashell[180735]: 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
Feb 01 04:17:38 my_device plasmashell[180735]: Toolbox not loading, toolbox package is either invalid or disabled.
Feb 01 04:17:38 my_device plasmashell[180735]: 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
Feb 01 04:17:38 my_device plasmashell[180735]: Toolbox not loading, toolbox package is either invalid or disabled.
Feb 01 04:17:39 my_device plasmashell[180735]: org.kde.plasma.kicker: Entry is not valid "org.kde.kontact.desktop" 0x5fe7a9a05220
Feb 01 04:17:39 my_device plasmashell[180735]: org.kde.plasma.kicker: Entry is not valid "org.kde.discover.desktop" 0x5fe7a9a05220
Feb 01 04:17:39 my_device plasmashell[180735]: org.kde.plasma.kicker: Entry is not valid "org.kde.kontact.desktop" 0x5fe7a9a05220
Feb 01 04:17:39 my_device plasmashell[180735]: org.kde.plasma.kicker: Entry is not valid "org.kde.discover.desktop" 0x5fe7a9a05220
Feb 01 04:17:39 my_device plasmashell[180735]: file:///usr/share/plasma/plasmoids/org.kde.plasma.private.systemtray/contents/ui/main.qml:50:9: QML KSortFilterProxyModel: Binding loop detected for property "sourceModel"
Feb 01 04:17:39 my_device plasmashell[180735]: file:///usr/share/plasma/plasmoids/org.kde.plasma.private.systemtray/contents/ui/main.qml:50:9: QML KSortFilterProxyModel: Binding loop detected for property "sourceModel"
Feb 01 04:17:39 my_device plasmashell[180735]: QFont::setPointSizeF: Point size <= 0 (0.000000), must be greater than 0
Feb 01 04:17:50 my_device plasmashell[180735]: The cached device pixel ratio value was stale on window update.  Please file a QTBUG which explains how to reproduce.
  • After the last log got printed, the panel appeared again and I noticed that the plasmashell memory usage has dropped down to ~300MB (I think it restarted automatically since I kept clicking on the widgets too many times in a short period)

My Device Information (inxi -Fz):

System:
  Kernel: 6.12.10-arch1-1 arch: x86_64 bits: 64
  Desktop: KDE Plasma v: 6.2.5 Distro: EndeavourOS
Machine:
  Type: Laptop System: ASUSTeK product: ASUS TUF Gaming F15 FX506LH_FX506LH
    v: 1.0 serial: <superuser required>
  Mobo: ASUSTeK model: FX506LH v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: FX506LH.310 date: 11/26/2021
Battery:
  ID-1: BAT1 charge: 29.2 Wh (79.8%) condition: 36.6/48.1 Wh (76.2%)
    volts: 12.1 min: 11.7
CPU:
  Info: 8-core model: Intel Core i7-10870H bits: 64 type: MT MCP cache:
    L2: 2 MiB
  Speed (MHz): avg: 800 min/max: 800/5000 cores: 1: 800 2: 800 3: 800 4: 800
    5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11: 800 12: 800 13: 800 14: 800
    15: 800 16: 800
Graphics:
  Device-1: Intel CometLake-H GT2 [UHD Graphics] driver: i915 v: kernel
  Device-2: NVIDIA TU117M [GeForce GTX 1650 Mobile / Max-Q] driver: nvidia
    v: 565.77
  Device-3: Sonix USB2.0 HD UVC WebCam driver: uvcvideo type: USB
  Display: wayland server: X.org v: 1.21.1.15 with: Xwayland v: 24.1.4
    compositor: kwin_wayland driver: X: loaded: nvidia
    gpu: i915,nvidia,nvidia-nvswitch resolution: 1: 1920x1080~60Hz
    2: 1920x1080~144Hz
  API: EGL v: 1.5 drivers: nvidia
    platforms: gbm,wayland,x11,surfaceless,device
  API: OpenGL v: 4.6.0 vendor: nvidia v: 565.77 renderer: NVIDIA GeForce
    GTX 1650/PCIe/SSE2
  API: Vulkan v: 1.4.303 drivers: N/A surfaces: xcb,xlib,wayland
  Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo
    de: kscreen-console,kscreen-doctor gpu: nvidia-settings,nvidia-smi
    wl: wayland-info x11: xdpyinfo, xprop, xrandr
Audio:
  Device-1: Intel Comet Lake PCH cAVS driver: snd_hda_intel
  Device-2: NVIDIA driver: snd_hda_intel
  API: ALSA v: k6.12.10-arch1-1 status: kernel-api
  Server-1: PipeWire v: 1.2.7 status: active
Network:
  Device-1: MEDIATEK MT7921 802.11ax PCI Express Wireless Network Adapter
    driver: mt7921e
  IF: wlan0 state: up mac: <filter>
  Device-2: Realtek RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
    driver: r8169
  IF: enp4s0 state: down mac: <filter>
Bluetooth:
  Device-1: IMC Networks Wireless_Device driver: btusb type: USB
  Report: btmgmt ID: hci0 state: up address: <filter> bt-v: 5.2
Drives:
  Local Storage: total: 476.94 GiB used: 81.16 GiB (17.0%)
  ID-1: /dev/nvme0n1 vendor: Micron model: 2210 MTFDHBA512QFD
    size: 476.94 GiB
Partition:
  ID-1: / size: 192.78 GiB used: 81.16 GiB (42.1%) fs: ext4
    dev: /dev/nvme0n1p3
  ID-2: /boot/efi size: 511 MiB used: 7.2 MiB (1.4%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  Alert: No swap data was found.
Sensors:
  System Temperatures: cpu: 68.0 C pch: 59.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Memory: total: 16 GiB available: 15.45 GiB used: 6.51 GiB (42.1%)
  Processes: 350 Uptime: 4d 11h 57m Shell: Bash inxi: 3.3.37

I haven’t filed a bug report before so please let me know if this is memory leak and if the ‘steps to reproduce’ are informative enough. I’m also on the latest version of KDE.

Thanks :slight_smile:

2 Likes

Sorry, OP, I can’t reproduce this. I can spamclick the tray icons and it’s all fine. No gigabytes of memory usage, no scaling error, no wayland crash due to open files, no reboot.

Note that I just listed four different symptoms, so you should consider this as 4 separate problems, until you can confirm otherwise.

Pretty big gap between 4KB and 3,000,000KB mate :smiley: Also pretty big gap between 128MB (0.4% of 32GB) and 3000MB. Probably any memory usage you’re seeing is just usage, not a leak. I can make my plasmashell memory usage jump several hundred megabytes with ease and have never seen a problem with it. 3GB seems excessive, though.

Memory usage won’t trigger a reboot, the kernel will kill processes using too much memory, if it needs memory and can’t get it. It’ll cause a ‘crash’, but not a reboot. Spontaneous reboot basically implies a hardware issue. That might be driver problems or might be actual faulty hardware.

You should definitely test this with a few changes:
New user account - eliminates that you changed something and broke it
Stable graphics driver - you’re running a beta test graphics driver and seeing graphics errors. This one’s a no-brainer. Use 550.144.03 for any chance at stability.
More stable distro - Try debian or fedora or maybe neon (since you think the problem is KDE). Endeavour doesn’t exactly have a rep for running smoothly.

So for example if it were me, I’d have a fedora live USB and test with that, and if I saw evidence of a KDE issue, I might switch to neon. Good luck!

2 Likes

Thanks pallaswept, I’ll try these out and give an update :slight_smile:

2 Likes

You can try GitHub - KDE/heaptrack: A heap memory profiler for Linux that will show you an actual picture of memory used.

4 Likes

Hi - one thing that might help narrow down what’s being investigated: plasmashell crashing due to “too many open files” is almost certainly the following NVIDIA issue: Fd leak with explicit sync and kde plasma - Linux - NVIDIA Developer Forums

In general, it might be worth testing out booting using the Nouveau drivers, then checking which issues you still experience there - that could help narrow down what’s a core plasmashell issue, and what’s at least being contributed to by the NVIDIA proprietary drivers.

1 Like

I’m on EndeavourOS and having a similar problem. I have 6 Firefox tabs open and konsole and this is the output of top sorted to highest memory usage


I have a couple of widgets on my panel, too. PlasMusic Toolbar, CPU temp/Disk usage/network/RAM usage from System monitor and also Discord.

Try removing it and see if that changes something.
If it does report the issue to its dev GitHub - ccatterina/plasmusic-toolbar: KDE Plasma widget that shows currently playing song information and provide playback controls.

If not other plasmoids, one by one.

Usually that’s a plasmoid issue.

1 Like