Bug 460813 - Unknown memory usage after screen lock
Summary: Unknown memory usage after screen lock
Status: RESOLVED NOT A BUG
Alias: None
Product: kscreenlocker
Classification: Plasma
Component: general (show other bugs)
Version: 5.26.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-21 15:38 UTC by bwqr
Modified: 2022-10-25 14:20 UTC (History)
2 users (show)

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


Attachments
Memory usage after logging out plasma session (253.48 KB, image/jpeg)
2022-10-22 15:09 UTC, bwqr
Details
Memory usage before logging out plasma shell (250.50 KB, image/png)
2022-10-22 15:09 UTC, bwqr
Details
More detailed memory usages (3.25 MB, image/jpeg)
2022-10-22 17:59 UTC, bwqr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bwqr 2022-10-21 15:38:06 UTC
SUMMARY
When I unlock the screen by typing password and hitting enter after locking the screen or suspending the computer, I observe significant increase in memory usage. This behavior does not happen all the time. it can happen randomly after several days of uptime. The interesting part is that I cannot see which application uses the memory. Even after logging out the KDE session, memory usage is just there. I could not debug this behavior and I hope to find some help from KDE devs.

An example of memory usage history:
* Before the lock or suspend, it is 10GB.
* After the unlocking, 20GB.
* After logging out, 10GB.

I can be sure that it happens just after the unlock and displaying the desktop since I can feel the desktop getting sluggish for a second. One additional note, the lock screen turns off the screen to save power, after a couple seconds, the screen turns on again - I could not find a way to turn off my screen from KDE.

STEPS TO REPRODUCE
1. Lock the screen
2. Unlock the screen

OBSERVED RESULT
The system memory usage spikes.

EXPECTED RESULT
The system memory should remain same

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Gentoo, kde-plasma/plasma-meta-5.26.1::gentoo
(available in About System)
KDE Plasma Version: 5.26.1
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.5

ADDITIONAL INFORMATION
uname: Linux 6.0.2-gentoo-bwqr-x86_64 #2 SMP PREEMPT Wed Oct 19 22:04:33 +03 2022 x86_64 AMD Ryzen 5 5600X 6-Core Processor AuthenticAMD GNU/Linux
gpu: amd rx 580
mesa: 22.2.1
Comment 1 bwqr 2022-10-21 15:59:22 UTC
Forgot to mention how I start the plasma, I run `dbus-run-session startplasma-wayland` in a tty console to start plasma.
Comment 2 Nate Graham 2022-10-21 17:30:13 UTC
What process is using all that memory? System Monitor or `top` will tell you.
Comment 3 bwqr 2022-10-21 17:36:15 UTC
That is the interesting part, nothing shows up in the top, htop or System Monitor. Neither running these tools as root or normal user changes anything. I also looked into slabtop, /proc/meminfo and dmesg and could not find a relevant information. Even though all  tools display high memory usage, no process seems to consume that much memory. What else can I do to debug this?
Comment 4 Nate Graham 2022-10-21 17:42:21 UTC
So what's telling you that the total usage is high? Can you attach a screenshot of it?
Comment 5 bwqr 2022-10-21 18:22:27 UTC
When I encounter the same behavior, I will take screenshots and upload them. But I can say that `used` tab of the `free -h` command, `used mem` section of the `top` command and `mem` bar in the htop shows similar memory usages which is really high. All this observations are made in the tty console after exitting the plasma session. There are so few processes in the top or htop, and none of them uses that much memory. With high memory usage, I mean 10GB memory out of 32GB is used by something.
Comment 6 bwqr 2022-10-22 15:09:10 UTC
Created attachment 153116 [details]
Memory usage after logging out plasma session

Here is a screenshot of htop after logging out plasma session when this behavior occurs.
Comment 7 bwqr 2022-10-22 15:09:54 UTC
Created attachment 153117 [details]
Memory usage before logging out plasma shell

And memory usage in htop before logging out plasma shell when this behavior occurs.
Comment 8 bwqr 2022-10-22 17:59:23 UTC
Created attachment 153124 [details]
More detailed memory usages

Here is a more detailed capture of memory usages. I have combined multiple htop screens into one image. Image at the top is captured first and the image at the bottom is captured last. Here are the things I have done before taking the specific image, the numbers indicate the image.

1. Computer resumed from suspend. Instead of unlocking the screen locker, I switched to tty2 and started the htop.
2. I switched back to tty1 and unlocked the screen locker. Workspace 1 is visible now.
3. Switched to workspace 3.
4. Killed all the applications.
5. Logged out from the session.

I also want to emphasize which application was running on which workspace, numbers indicates the workspace:
1. Firefox, chromium, evince
3. Thunderbird, rhythmbox
Comment 9 Nate Graham 2022-10-24 18:18:03 UTC
In the latest screenshot, your memory is mostly being used by by Thunderbird, Firefox, Evince, and Rhythmbox. Doesn't seem like there's a KDE bug there.

In the one that shows multiple plasmashell processes open, each one is using a normal-ish amount of memory; the bug is that you have more than one running? How did that happen? Are you running `dbus-run-session startplasma-wayland` multiple times without killing the old sessions? When you do things manually, you become responsible for this sort of thing.
Comment 10 bwqr 2022-10-24 20:36:56 UTC
(In reply to Nate Graham from comment #9)
> In the latest screenshot, your memory is mostly being used by by
> Thunderbird, Firefox, Evince, and Rhythmbox. Doesn't seem like there's a KDE
> bug there.
I also started to think like this. The only thing related to KDE is that this behavior is triggered when screen gets locked in plasma shell. I am normally using sway and this behavior did not happen for once, the reason may be that I do not use any screen locker while using sway.

> In the one that shows multiple plasmashell processes open, each one is using
> a normal-ish amount of memory; the bug is that you have more than one
> running? How did that happen? Are you running `dbus-run-session
> startplasma-wayland` multiple times without killing the old sessions? When
> you do things manually, you become responsible for this sort of thing.
Actually it is not running multiple times. Each image in the combined one, which contains 5 different images, just shows the htop taken at different times, not different scrolls of same htop.

I will try another distro to check if this behavior occur in order to identify that issue is related to gentoo or not. It may be a bug in gtk wayland. I am going to close this bug. If you can guide me, I will appreciate it. Thanks for your time anyway.
Comment 11 Nate Graham 2022-10-24 21:34:57 UTC
https://bugsfiles.kde.org/attachment.cgi?id=153117 does show multiple plasmashell instances.
Comment 12 bwqr 2022-10-25 06:20:19 UTC
(In reply to Nate Graham from comment #11)
> https://bugsfiles.kde.org/attachment.cgi?id=153117 does show multiple
> plasmashell instances.

Ooh, you were referencing this attachment. Well, they are just threads of plasmashell. Purplish rows indicate the threads. White ones indicate the process itself.
Comment 13 Nate Graham 2022-10-25 14:20:10 UTC
Oops, thanks!