Bug 441543 - ksystemstats memory leak
Summary: ksystemstats memory leak
Status: CONFIRMED
Alias: None
Product: ksysguard
Classification: Applications
Component: ksysguard (show other bugs)
Version: 5.20.5
Platform: Debian stable Linux
: NOR major
Target Milestone: ---
Assignee: David Edmundson
URL:
Keywords: efficiency
Depends on:
Blocks:
 
Reported: 2021-08-25 19:29 UTC by MIchael Giardino
Modified: 2023-05-28 16:38 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Valgrind log (159.14 KB, application/gzip)
2021-08-27 06:11 UTC, Ömer Fadıl USTA
Details
Heaptrack of newly reastarted program (14.78 KB, application/gzip)
2021-08-29 20:06 UTC, MIchael Giardino
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MIchael Giardino 2021-08-25 19:29:33 UTC
After upgrading to Debian 11 bullseye (ksysguard 5.20.5), ksystemstats gets a major memory leak. It eventually gets resident memory in the GBs and matching swap, basically bringing the system to a halt from swapping.


STEPS TO REPRODUCE
1. boot system
2. leave running
3. maybe suspend? it is a laptop

OBSERVED RESULT


EXPECTED RESULT

Ever increasing memory usage, into the GBs

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: debian 11 - Plasma 5.20.5
(available in About System)
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Comment 1 Ömer Fadıl USTA 2021-08-27 06:11:08 UTC
Created attachment 141081 [details]
Valgrind log

I can confirm this bug, leak was much worse on previous versions. Valgrind logs attached
Comment 2 David Edmundson 2021-08-27 15:53:19 UTC
Any chance you can do the same with heaptrack?


We're seeing a huge heap usage:
==11108== HEAP SUMMARY:
 936,250,898 bytes allocated


so you're right something is going wrong, but the leak summary section doesn't have all that. So the bug leak during runtime is being cleaned up in the final destruction.
Comment 3 MIchael Giardino 2021-08-29 20:06:49 UTC
Created attachment 141130 [details]
Heaptrack of newly reastarted program

This is a heaptrack after the restart, but if I'm reading it correctly it has already leaked a bit in the minute it was running.

I can connect it to the process when it begins to really leak, but given the amount of data it generates and how long it takes to trigger, I don't think i can let it run from now until then. Let me know if you can think of something else I can do.

heaptrack output will be written to "/home/mikel/Downloads/heaptrack.ksystemstats.121644.gz"
injecting heaptrack into application via GDB, this might take some time...
injection finished
heaptrack stats:
        allocations:            2680
        leaked allocations:     20
        temporary allocations:  365
removing heaptrack injection via GDB, this might take some time...
ptrace: No such process.
No symbol table is loaded.  Use the "file" command.
The program is not being run.
Heaptrack finished! Now run the following to investigate the data:
Comment 4 kolAflash 2022-11-04 07:51:01 UTC
Has this been fixed yet?
Maybe just upstream?

I'm running Debian-11 and the ksystemstats process is currently using 5 GB of memory.
$ ps -o pid,args,pmem,rss,vsz -C ksystemstats
    PID COMMAND                     %MEM   RSS    VSZ
   1799 /usr/bin/ksystemstats       36.7 5258904 5378280
I got a "System Monitor Sensor" widget/plasmoid in my plasma control bar.
It's showing the memory consumption. And ironically this may seem to cause the memory leak.  

Duplicate reports:
https://invent.kde.org/plasma/ksystemstats/-/issues/1
https://bbs.archlinux.org/viewtopic.php?id=263203
https://forum.manjaro.org/t/ksystemstats-memory-leak/39409/3
https://forums.debian.net/viewtopic.php?p=761527&sid=9600169c07a3f5aabf9f3d003e2c7346#p761527
https://unix.stackexchange.com/questions/679667/what-causes-ksystemstats-to-run-and-consume-many-gb-of-ram-how-to-prevent-this
https://www.reddit.com/r/kde/comments/v5sg1q/workaround_for_this_memory_leak/
Comment 5 Riccardo Robecchi 2022-11-24 12:08:35 UTC
Is it possible this is related to bug 460370 as well? That one affects the new System Monitor.
Comment 6 OneBugReport 2023-05-28 16:38:12 UTC
Still not fixed

$ ps -o pid,args,pmem,rss,vsz -C ksystemstats                                                                                                                               
                 PID COMMAND                  %MEM      RSS              VSZ
1040153 /usr/bin/ksystemstats       25.0           3990380      28240352