http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html says that MemoryLimit implies "MemoryAccounting=true". But it's not the case. If I don't put an explicit "MemoryAccounting=true" in the unit file below, service control groups under memory is not created and memory limit doesn't work. ---- [Unit] Description=foo After=network.target [Service] User=bar WorkingDirectory=/home/bar ExecStart=/usr/bin/foo Restart=always RestartSec=5min MemoryLimit=256M [Install] WantedBy=multi-user.target ---- [root@quux ~]# systemctl show foo -p MemoryLimit MemoryLimit=268435456 [root@quux ~]# systemctl show foo -p MemoryAccounting MemoryAccounting=no
Note that setting MemoryLimit= effectively turns on MemoryAccounting= but it won't show it with "systemctl show", since that actually shows the original MemoryAccounting= setting. Or in other words, there's a distinction between the MemoryAccounting= setting (which is unaffected by MemoryLimit=, as you experienced), and the actual memory accounting which is turned on in the kernel either by using MemoryAccounting= or by MemoryLimit=. If you follow wht I mean. Anyway, this is actually intended behaviour, but certainly something we could document better. Hence renaming the bug accordingly.
We dropped the offending sentences now from the man page. Closing. See: https://github.com/systemd/systemd/pull/9669
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.