KDE runs applications as systemd services (How does KDE use systemd to run applications as services?).
If I wanted to limit the size of memory used by specific application using systemd directives MemoryHigh and MemoryMax how can I do it?
KDE runs applications as systemd services (How does KDE use systemd to run applications as services?).
If I wanted to limit the size of memory used by specific application using systemd directives MemoryHigh and MemoryMax how can I do it?
man systemctl
then look for set-property
.
To use systemctl set-property
you need to know the name of unit file but this name (as shown in my other linked question) is dynamic (looks like app-org.kde.krusader@2afd24ec5acc40599209dbdba916b96a.service
) and not presented when starting application.
If you want to set that for all apps, put it in ~/.config/systemd/user/app-.service.d/*.conf
should do the job.
For a specific application, you might have to modify the desktop file, and wrap the command line in a shell script. You can get the systemd unit name from cat /proc/$$/cgroup
.
You can change config for a single app with overrides like ~/.config/system/user/app-org.kde.kwrite@.service.d/*.conf
. Systemd treats the part after “@” as a parameter to a template, so you can override the template.
Jin Liu described in details (thank you Jin!) how this can be done in the blog post Limit Application Memory Usage with systemd - KDE Blogs
There’s a companion discussion topic at Limit Application Memory Usage with systemd - KDE Blogs if anyone has any further questions regarding this topic.