Bug 436061 - Extreme memory usage on idle system
Summary: Extreme memory usage on idle system
Status: REPORTED
Alias: None
Product: plasmashell
Classification: Plasma
Component: generic-performance (show other bugs)
Version: 5.21.3
Platform: Archlinux Linux
: NOR grave
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: efficiency
Depends on:
Blocks:
 
Reported: 2021-04-22 21:17 UTC by J.O. Aho
Modified: 2021-09-11 16:01 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Results from gdb, pmap and output from the replaced plasmashell (308.71 KB, text/x-log)
2021-04-22 21:17 UTC, J.O. Aho
Details
New crash information added by DrKonqi (5.67 KB, text/plain)
2021-05-19 21:02 UTC, J.O. Aho
Details
result of gdb --batch --quiet -ex "set pagination off" -ex "thread apply all bt" -ex "detach" -ex "quit" pid 13064 (59.18 KB, text/plain)
2021-09-11 15:23 UTC, J.O. Aho
Details

Note You need to log in before you can comment on or make changes to this bug.
Description J.O. Aho 2021-04-22 21:17:55 UTC
Created attachment 137809 [details]
Results from gdb, pmap and output from the replaced plasmashell

SUMMARY
Htop showed that plasmashell process was taking ~79% of all memory on a system with 64G Ram (62.8G accessible memory), the machine was sluggish as things started to swap out from memory to disk.

STEPS TO REPRODUCE
1. Unknown, could be related to network that are sometimes a bit unstable


OBSERVED RESULT
After run "plasmashell --replace" (had run it earlier this week, so second time for the session), I got quite many rows of
[14622:27:0422/225123.533802:ERROR:stun_port.cc(96)] Binding request timed out from 0.0.0.x:53362 (any)
printed out on the shell for the previous plasmashell process.


EXPECTED RESULT
Retries shouldn't be done until previous request has timed out or kill the previous request.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.81.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Xorg: 1.20.11
nVidia: 465.24.02
Kernel: 5.11.14
OS-Type: 64-bit

There are two plasma5 sessions running at the same time, sometimes this happens on both instances at the same time, sometimes it's just one instance. System becomes unresponsive when swap is used (swap on SSD).
Comment 1 J.O. Aho 2021-04-22 21:23:10 UTC
For me this has happen for a quite long time, not sure exactly when I first encountered this, but at least since summer 2020. 

Most of the time it's gone so far that the system started to swap and then there is no chance to get any information and the only thing to do is to reboot. For me it starts to be at a such level that I have to consider of switching to another desktop environment after 18 years with KDE/Plasma.
Comment 2 Miguel Hernandez 2021-05-02 20:07:09 UTC
Today I've observed this problem on Manjaro.

The plasmashell process consumes until 11GB on startup and after a few seconds it decreases to 5GB (24GB RAM).

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.81.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Xorg: 1.20.11
Kernel: 5.12.0
OS-Type: 64-bit
Comment 3 Miguel Hernandez 2021-05-02 20:20:41 UTC
I think I've found the root cause on my system: the slideshow background changer. After set a static image as wallpaper the plasmashell process decrease to 321MB. I use Wikimedia Commons as provider and the daily image is really too big (https://upload.wikimedia.org/wikipedia/commons/f/f9/Lady_with_an_Ermine_-_Leonardo_da_Vinci_-_Google_Art_Project.jpg).
Comment 4 J.O. Aho 2021-05-03 06:12:15 UTC
@Miguel:
Yes, the wallpaper slideshow been known to leak memory for years.

Myself I have just a fixed image, the desktop directory view is the only widget I  have. So we do not have the same reason for the memory leak and in my case it's quite random in both how fast it happen, when it seems to happen and it do happen for two users.
Comment 5 J.O. Aho 2021-05-04 06:03:21 UTC
@i@guoyunhe.me:

Never used POTD, so sorry reverting back what you changed.
Comment 6 J.O. Aho 2021-05-19 21:02:50 UTC
Created attachment 138579 [details]
New crash information added by DrKonqi

plasmashell (5.21.5) using Qt 5.15.2

- What I was doing when the application crashed:
Idle with a VirtualBox machine  running idle

- Unusual behavior I noticed:
Desktop somewhat slow

-- Backtrace (Reduced):
#6  0x00007fc9967b486a in __gnu_cxx::__verbose_terminate_handler() () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#7  0x00007fc9967c0d3a in __cxxabiv1::__terminate(void (*)()) (handler=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#8  0x00007fc9967c0da7 in std::terminate() () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#9  0x00007fc9967c1b05 in __cxxabiv1::__cxa_pure_virtual() () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/pure.cc:50
#10 0x00007fc996fd3833 in QOpenGLContext::doneCurrent() () at /usr/lib/libQt5Gui.so.5
Comment 7 Zoltán KADA 2021-07-27 15:10:53 UTC
The error occurred three times this week. I noticed this twice after I returned from the suspend.

KDE Neon User Edition, Plasma 5.22.3 , Qt 5.15.3, Wayland.

Detailed Memory Information:
Summary
The process plasmashell (with pid 180494) is using approximately 8.2 GB of memory.
It is using 8.2 GB privately, and a further 54.3 MB that is, or could be, shared with other programs.
Dividing up the shared memory between all the processes sharing that memory we get a reduced shared memory usage of 13.0 MB. Adding that to the private usage, we get the above mentioned total memory footprint of 8.2 GB.
51.8 MB is swapped out to disk, probably due to a low amount of available memory left.
Library Usage
The memory usage of a process is found by adding up the memory usage of each of its libraries, plus the process's own heap, stack and any other mappings, plus the stack of its 20 threads.
Private
more
8499932 KB	[heap]
38400 KB	/i915 (deleted)
5772 KB	/memfd:JSGCHeap:QtQml (deleted)
4344 KB	/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1
2268 KB	/home/zolti/.cache/plasma_theme_breeze-dark_v5.84.0.kcache
Shared
more
6988 KB	/memfd:wayland-shm (deleted)
5008 KB	/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
3600 KB	/usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.15.3
3516 KB	/home/zolti/.cache/ksycoca5_en-GB_PP3ToSErqv9Dhsf_Sklg_QMwnoQ= (deleted)
2676 KB	/var/cache/fontconfig/0b633c97-f9ee-40cb-84f9-73cfabe3af6c-le64.cache-7
Totals
Private	8573924 KB	(= 8660 KB clean + 8565264 KB dirty)
Shared	55648 KB	(= 41100 KB clean + 14548 KB dirty)
Rss	8629572 KB	(= Private + Shared)
Pss	8587253 KB	(= Private + Shared/Number of Processes)
Swap	53008 KB
Full Details
Information about the complete virtual space for the process is available, with sortable columns. An empty filename means that it is an anonymous mapping.
Comment 8 J.O. Aho 2021-09-11 15:22:16 UTC
I had a bad episode a few days ago, one or two sessions plasmashell had used up 61G RAM and caused a heavy use of the 8G swap, which made the machine completely unresponsive, wasn't possible to login in via ssh, screen frozen but heavy use of the SSD on which the swap slice is located on.

At that time I had the following installed:
plasma: 5.22.5
kde framework: 5.85.0
Qt: 5.15.2
Kernel: 5.13.12 (64bit)
Xorg: 1.20.13
nVidia driver: 470.63.01

My current session has raised from 0.8% to 1.2% of the 63G that is left after kernel has been loaded.
It seems that there are quite many ThreadWeaver threads in GlobalQueue, and it don't seems to be flushed out at all, it just keep on getting more of those.

See gdb_for_pid_13064.txt
Comment 9 J.O. Aho 2021-09-11 15:23:48 UTC
Created attachment 141479 [details]
result of gdb --batch --quiet -ex "set pagination off" -ex "thread apply all bt" -ex "detach" -ex "quit" pid 13064
Comment 10 J.O. Aho 2021-09-11 16:01:56 UTC
Got the maps of the pid 13064 and it's sub processes, as it 15k I had to upload it to 
https://anonfiles.com/h1f3XdGdua/maps_13064_txt