[systemd-devel] MemoryLimit for user unit

Stefan Schweter stefan at schweter.it
Sun Nov 12 17:14:38 UTC 2017


Hi systemd-users,

I tried to add a memory limit for a user service unit (inspired by [1]),
it looks like:

[Service]
# ....
MemoryAccounting=true
MemoryLimit=1G

Now the problem is that the (user) service consumes more than 1G without
being terminated.

htop shows a memory consumption of 1.4 GB. The output of `systemd-cgtop` is:

Control Group                             Tasks   %CPU   Memory  Input/s
Output/s
/                                             -    1.5     1.7G        -

/user.slice                                  46    0.4    14.3M        -

/user.slice/user-1001.slice                  46    0.4    14.2M        -

/init.scope                                   1      -     1.4M        -

/system.slice


So my question is how would MemoryLimit= work for a user unit?

My system is Debian 9 with systemd:

$ systemctl --version
systemd 232
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP
+LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS
+KMOD +IDN


Thanks in advance + regards.

Stefan

[1] http://0pointer.de/blog/projects/resources.html


More information about the systemd-devel mailing list