Implement free memory notifier
Needs ReviewPublic

Authored by McPain on Wed, Nov 28, 2:04 PM.

Details

Reviewers
broulik
ngraham
Group Reviewers
VDG
Summary

FreeMemoryNotifier will warn when free RAM is running out.
By default, it is 25% without swap space.

Like freespacenotifier, it will check every 5 seconds for amount of free memory and
warn every time when it drops below limit and when free space amount drops more than half of previous value

User can either kill most greedy process immediately or open a task manager to kill unneeded processes manually.
Task manager was patched to ignore global config and show only user own processes, sorted by memory used in descending order.

The settings are available at new KCM located in Desktop Behavior category.
KCM and KDED modules are linked through DBus - committed settings are applied immediately.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
McPain created this revision.Wed, Nov 28, 2:04 PM
Restricted Application added a project: Plasma. · View Herald TranscriptWed, Nov 28, 2:04 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
McPain requested review of this revision.Wed, Nov 28, 2:04 PM
ngraham added a reviewer: VDG.Wed, Nov 28, 2:46 PM
ngraham added a subscriber: ngraham.

Thanks for all the work!

...But is this actually useful or actionable for the majority of users? Free space is a fairly understandable concept: if you run out, you need to delete things to make more room before you can add more stuff. It won't fix itself unless the user does something. But memory pressure requires a much greater technical understanding and isn't subject to the same conditions. When the system is using up 75% of the available memory, there isn't necessarily a problem at all. Apps will move to swap automatically. Even if there is a problem, it's only temporary, and it may fix itself if the user does nothing as the system shuffles things around.

I worry that this notifier would just be yet another annoying pop-up that people dismiss because they don't understand it.

Thanks for all the work!

...But is this actually useful or actionable for the majority of users? Free space is a fairly understandable concept: if you run out, you need to delete things to make more room before you can add more stuff. It won't fix itself unless the user does something. But memory pressure requires a much greater technical understanding and isn't subject to the same conditions. When the system is using up 75% of the available memory, there isn't necessarily a problem at all. Apps will move to swap automatically. Even if there is a problem, it's only temporary, and it may fix itself if the user does nothing as the system shuffles things around.

I worry that this notifier would just be yet another annoying pop-up that people dismiss because they don't understand it.

Sometimes I see what happens if you're running out of memory and oom can't do anything - the whole system halts and only solution for this is hard reset with all unsaved data lost.
25% is not hardcoded value, you can reduce threshold down to 1% and also you can include your swap space in settings.

abetts added a subscriber: abetts.Wed, Nov 28, 2:58 PM

Is having this feature an optional feature? Can it be turned off?

Is having this feature an optional feature? Can it be turned off?

I'll make the notification "disableable" tomorrow

Sometimes I see what happens if you're running out of memory and oom can't do anything - the whole system halts and only solution for this is hard reset with all unsaved data lost.
25% is not hardcoded value, you can reduce threshold down to 1% and also you can include your swap space in settings.

The problem is that none of this is appropriate to expose regular users to. If this feature goes in, it needs perfect defaults, because 99.99% of users will never change the defaults even if they are annoyed by them.

I would recommend changing the default threshold from 25% to 10%, and automatically detect swap space rather than making the user configure it.

I don't think that this is useful - sorry. I run out of memory about once every five years, so polling every five seconds is way too often and a waste of resources. On the other hand the time when it happens polling 5 sec is way too low as then we are already dead. This can only happen if an application eats memory and then it's going fast.

I don't think that this is useful - sorry. I run out of memory about once every five years, so polling every five seconds is way too often and a waste of resources. On the other hand the time when it happens polling 5 sec is way too low as then we are already dead. This can only happen if an application eats memory and then it's going fast.

Agreed.

ngraham requested changes to this revision.Wed, Nov 28, 6:01 PM
This revision now requires changes to proceed.Wed, Nov 28, 6:01 PM

Given there is some negativity in the feedback I do want to point out that it's cool to still upload whatever to the KDE store/wider ecosystem. Not everything run in plasma needs to be from plasma; we go to great lengths to make sure that's the case.

There's also an alternative that I'd like to suggest:
According to https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt there's a system called "memory pressure" you can watch for events on a specific FD with various levels of out-of-memory-ness. A lot cheaper than polling, far more reliable, and following the system's OOM configuration. Getting that in at a frameworks level so it can be hooked up to notifications in this case, but also garbage collections in UI code could be pretty cool.

plasma-workspace/freememorynotifier/freememorynotifier.cpp
56

how is that 1 minute?

There's also an alternative that I'd like to suggest:
According to https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt there's a system called "memory pressure" you can watch for events on a specific FD with various levels of out-of-memory-ness. A lot cheaper than polling, far more reliable, and following the system's OOM configuration. Getting that in at a frameworks level so it can be hooked up to notifications in this case, but also garbage collections in UI code could be pretty cool.

Thanks. Any examples in KDE? I can't implement this from scratch right now.

McPain updated this revision to Diff 46892.Wed, Dec 5, 11:10 AM

Default limit: 25% -> 10%
Fix typos
Auto detect swap, removed "includeSwap" setting
KSysGuard: show kill button (implemented in D17366)

McPain marked an inline comment as done.Wed, Dec 5, 11:12 AM