[LIKELY INVALID] Huge memory allocation on plasmashell with proprietary driver; nouveau is fine

See this:
https://bugs.kde.org/show_bug.cgi?id=368838

I’m the reporter and i’m badly affected. Plasma5 is unusable with the proprietary driver.
Even if is all explained in the bug report, i summarize here:

As soon as plasmashell does something graphical, his memory usage grows and never goes down (showing the main menu, moving a plasmoid and so on).
Yesterday it reached 700MB from 500MB over the weekend (always-on pc) while i was away!

So i tried vesa first, then nouveau and ram consumption stopped at about 255MB; where plasma5 with the proprietary driver starts with more than 300MB in use.

I also tried all of the possible InitialPixmapPlacement values (0…4) and to disable the pixmap cache to no avail.

In the end, i’m forced to restart the plasmashell process every now and then.

Tried nvidia 367.35 and 370.28

nvidia-bug-report logs here:
http://wpage.unina.it/aorefice/sharevari/nvidia-bug-report.log.gz

Guys, somebody can at least test if they are able to reproduce?

test Is simple/easy:

  1. Logout and login again to the kde session
  2. From a terminal:
  3. #grep VmRSS /proc/`pidof plasmashell`/status
    
  4. Note the value (value1)
  5. Open the "start" menu, open the calendar, move a plasmoid, resize it... use plasma!
  6. Again, from a terminal:
  7. #grep VmRSS /proc/`pidof plasmashell`/status
    
  8. Note the value (value2)
  9. Post the result of value2-value1

Here i’m using qt5.7, plasma-framework 5.26, plasma-workspace 5.7.5 and qt 5.7.0
Thanks to anyone who will test in advance

Hi,
is it true that the memory usage value “never goes down”? Does it not eventually stabilize? Please run the application until your system starts swapping. Anything before that is too early to conclude that memory usage never goes down.

That the proprietary driver uses more system memory than others may well be a known limitation, which isn’t strictly speaking a bug. Only if the growth is unbounded is there a bug.

Well, it may happens that sometimes it unallocates “a bunch of MB” after allocating 10X"a bunch of MB"

locked it at 500MB,unlocked it at 700MB; i bet that in a month of unuse it would have started to swap too.

Now, i can’t let it run for so much time waiting for it to start swapping, so i’ll try to use it till it will start swap.

I managed to make it swap by looping through some simple xdotool commands that send shortcuts keys to show the plasma background configuration window, then opens another window to download new wallpers, close both the windows and reiterate.

#sleep 5 ; while true ; do xdotool keydown alt key d ; sleep 1 ; xdotool key s ; sleep 1 ; xdotool keyup alt ; xdotool mousemove 2490 928 click 1 ; sleep 1 ; xdotool keydown alt key F4 ; sleep 1 ; xdotool keydown alt key F4 ; xdotool keyup alt ; done

Let it run for about 20 minutes and here is the system state:

# free
              total        used        free      shared  buff/cache   available
Mem:        8123968     7101320      126228      374856      896420       74704
Swap:       7393592     1837388     5556204

A script that sorts apps by swap usage reports:

Overall swap used: 3509535
PID=6722 - Swap used: 104 - (start_kdeinit )
PID=26402 - Swap used: 144 - (sleep )
PID=4563 - Swap used: 160 - (sleep )
PID=576 - Swap used: 176 - (gpm )
PID=16720 - Swap used: 216 - (timeout )
PID=7628 - Swap used: 224 - (inotifywait )
PID=5924 - Swap used: 288 - (ksysguardd )
PID=485 - Swap used: 352 - (fcron )
PID=16721 - Swap used: 416 - (inotifywait )
PID=24901 - Swap used: 496 - (dbus-daemon )
PID=10331 - Swap used: 512 - (tincd )
PID=764 - Swap used: 520 - (usbhid-ups )
PID=480 - Swap used: 576 - (ups.sh )
PID=7609 - Swap used: 576 - (sh )
PID=589 - Swap used: 584 - (dnsmasq )
PID=3888 - Swap used: 608 - (dbus-daemon )
PID=655 - Swap used: 616 - (upsd )
PID=24175 - Swap used: 672 - (dbus-daemon )
PID=16986 - Swap used: 696 - (screen )
PID=193 - Swap used: 740 - (systemd-journal )
PID=7610 - Swap used: 768 - (sh )
PID=555 - Swap used: 776 - (vsftpd )
PID=547 - Swap used: 808 - (StartPreload.sh )
PID=10339 - Swap used: 840 - (sh )
PID=516 - Swap used: 848 - (unison.sh )
PID=7608 - Swap used: 856 - (tty_switch.sh )
PID=23550 - Swap used: 864 - (rip_paralax.sh )
PID=554 - Swap used: 872 - (systemd-logind )
PID=481 - Swap used: 896 - (dbus-daemon )
PID=6626 - Swap used: 904 - (startkde )
PID=3882 - Swap used: 988 - (at-spi-bus-laun )
PID=542 - Swap used: 1016 - (tor )
PID=546 - Swap used: 1048 - (sshd )
PID=24891 - Swap used: 1104 - (sshd )
PID=6752 - Swap used: 1168 - (kwrapper5 )
PID=3457 - Swap used: 1176 - (obexd )
PID=1 - Swap used: 1198 - (systemd )
PID=6919 - Swap used: 1200 - (at-spi2-registr )
PID=1957 - Swap used: 1224 - (dconf-service )
PID=549 - Swap used: 1256 - (automount )
PID=9841 - Swap used: 1400 - (gvfs-udisks2-vo )
PID=26058 - Swap used: 1504 - (login )
PID=677 - Swap used: 1764 - (sshd )
PID=748 - Swap used: 1764 - (sshd )
PID=476 - Swap used: 1784 - (sudo )
PID=9849 - Swap used: 1784 - (gvfs-mtp-volume )
PID=3274 - Swap used: 1792 - (gvfsd-fuse )
PID=3066 - Swap used: 1832 - (gvfsd )
PID=24938 - Swap used: 1864 - (gconfd-2 )
PID=7069 - Swap used: 1888 - (gconfd-2 )
PID=974 - Swap used: 1928 - (dbus-daemon )
PID=9845 - Swap used: 1928 - (gvfs-gphoto2-vo )
PID=599 - Swap used: 1936 - (openvpn )
PID=720 - Swap used: 2208 - (systemd )
PID=9898 - Swap used: 2348 - (gvfsd-network )
PID=1888 - Swap used: 2376 - (upowerd )
PID=2492 - Swap used: 2669 - (file.so )
PID=562 - Swap used: 2696 - (sddm )
PID=600 - Swap used: 2864 - (openvpn )
PID=6621 - Swap used: 2864 - (sddm-helper )
PID=6723 - Swap used: 2937 - (kdeinit5 )
PID=525 - Swap used: 3001 - (tinyproxy )
PID=528 - Swap used: 3033 - (tinyproxy )
PID=529 - Swap used: 3033 - (tinyproxy )
PID=530 - Swap used: 3033 - (tinyproxy )
PID=531 - Swap used: 3033 - (tinyproxy )
PID=532 - Swap used: 3033 - (tinyproxy )
PID=533 - Swap used: 3033 - (tinyproxy )
PID=534 - Swap used: 3033 - (tinyproxy )
PID=535 - Swap used: 3033 - (tinyproxy )
PID=536 - Swap used: 3033 - (tinyproxy )
PID=538 - Swap used: 3033 - (tinyproxy )
PID=4950 - Swap used: 3088 - (kio_http_cache_ )
PID=544 - Swap used: 3128 - (syslog-ng )
PID=728 - Swap used: 3294 - ((sd-pam) )
PID=445 - Swap used: 3385 - (file.so )
PID=9854 - Swap used: 3472 - (gvfsd-trash )
PID=231 - Swap used: 4048 - (systemd-udevd )
PID=8114 - Swap used: 4148 - (klauncher )
PID=8106 - Swap used: 4191 - (kdeinit4 )
PID=10055 - Swap used: 4928 - (gvfsd-metadata )
PID=6815 - Swap used: 4992 - (xembedsniproxy )
PID=6725 - Swap used: 5176 - (klauncher )
PID=9906 - Swap used: 5844 - (gvfsd-smb-brows )
PID=6794 - Swap used: 5864 - (kactivitymanage )
PID=10342 - Swap used: 5944 - (dolphin )
PID=9941 - Swap used: 5960 - (gvfsd-dnssd )
PID=6789 - Swap used: 5992 - (polkit-kde-auth )
PID=25134 - Swap used: 6056 - (bash )
PID=6781 - Swap used: 6176 - (kactivitymanage )
PID=6799 - Swap used: 6240 - (kscreen_backend )
PID=479 - Swap used: 6280 - (cupsd )
PID=7557 - Swap used: 6304 - (xbindkeys_higgi )
PID=31750 - Swap used: 6800 - (kiod5 )
PID=24760 - Swap used: 6864 - (kwalletd5 )
PID=6839 - Swap used: 6928 - (knemo )
PID=6737 - Swap used: 7096 - (kaccess )
PID=6754 - Swap used: 7248 - (ksmserver )
PID=8588 - Swap used: 7384 - (kuiserver5 )
PID=1960 - Swap used: 7456 - (udisksd )
PID=10280 - Swap used: 7816 - (kdeconnectd )
PID=31929 - Swap used: 8016 - (kwalletd )
PID=6751 - Swap used: 8704 - (kglobalaccel5 )
PID=7957 - Swap used: 8704 - (knotify4 )
PID=6825 - Swap used: 8896 - (kmix )
PID=8173 - Swap used: 9263 - (kded4 )
PID=540 - Swap used: 10240 - (privoxy )
PID=556 - Swap used: 11560 - (haveged )
PID=1932 - Swap used: 14328 - (polkitd )
PID=6729 - Swap used: 15865 - (kded5 )
PID=24765 - Swap used: 18640 - (xfreerdp )
PID=16987 - Swap used: 19840 - (bash )
PID=26066 - Swap used: 20304 - (bash )
PID=591 - Swap used: 21312 - (colord )
PID=24808 - Swap used: 23160 - (xfreerdp )
PID=24747 - Swap used: 23636 - (krdc )
PID=2484 - Swap used: 24760 - (dolphin )
PID=17194 - Swap used: 27768 - (gbr3 )
PID=6822 - Swap used: 51580 - (gbr3 )
PID=6766 - Swap used: 67480 - (krunner )
PID=1772 - Swap used: 105208 - (kwin_x11 )
PID=30852 - Swap used: 201720 - (Web Content )
PID=6581 - Swap used: 203512 - (Xorg )
PID=30713 - Swap used: 294592 - (firefox )
PID=6827 - Swap used: 540160 - (Telegram )
PID=23775 - Swap used: 585940 - (qbittorrent )
PID=5915 - Swap used: 916298 - (plasmashell )

plasmashell status according to

# cat /proc/`pidof plasmashell`/status
Name:   plasmashell
State:  S (sleeping)
Tgid:   5915
Ngid:   0
Pid:    5915
PPid:   1
TracerPid:      0
Uid:    0       0       0       0
Gid:    0       0       0       0
FDSize: 256
Groups: 0 1 2 3 4 6 10 19 92 1000 
NStgid: 5915
NSpid:  5915
NSpgid: 6723
NSsid:  6723
VmPeak: 11305852 kB
VmSize: 11266120 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   6135180 kB
VmRSS:   5828812 kB
RssAnon:         5301068 kB
RssFile:          195912 kB
RssShmem:         331832 kB
VmData:  8231196 kB
VmStk:       164 kB
VmExe:       576 kB
VmLib:    134068 kB
VmPTE:     14224 kB
VmPMD:        52 kB
VmSwap:   523328 kB
HugetlbPages:          0 kB
Threads:        28
SigQ:   3/31701
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000001006
SigCgt: 00000001800104e8
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
CapAmb: 0000000000000000
Seccomp:        0
Cpus_allowed:   f
Cpus_allowed_list:      0-3
Mems_allowed:   00000000,00000001
Mems_allowed_list:      0
voluntary_ctxt_switches:        860348
nonvoluntary_ctxt_switches:     35171

For completeness, i tested the same with nouveau.
Yes, the leak is still there, but is much more contained.
In 3 minutes,
With nvidia proprietary driver, that script makes plasmashell eats about 258MB
With nouveau it eats almost 150MB
So maybe the bug lies in plasmashell after all, but do you consider normal that proprietary drive eats so much more ram?

If the leak can be reproduced with another driver, it is likely that the bug doesn’t lie in the driver.
The fact that the proprietary driver consumes more system memory isn’t proof of a bug in it, and in fact it can well be expected behavior.

Right.

At the end, it seems nvidia prop. is not using “SO” much more memory than nouveau, in the same conditions, nvidia is taking about 30% ram more than nouveau. (and not 70% more)

According to:
https://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html
Qtquick seems to default to NOT using threads with mesa drivers; hence the ram consumption.

Thanks for your attention.