[systemd-devel] MemoryLimit for user unit
Kai Krakow
hurikhan77 at gmail.com
Mon Nov 13 00:53:05 UTC 2017
Am Sun, 12 Nov 2017 18:14:38 +0100
schrieb Stefan Schweter <stefan at schweter.it>:
> 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.
As far as I could see, this limits the amount of RAM occupied. It
doesn't stop the memory from being swapped out. You need to limit swap
memory, too. Take note that swap accounting may have noticeable
overheads and as such is not enabled by default on many systems.
> 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?
Maybe you want to apply the limit to a slice? Your output of cgtop
doesn't show any service units...
--
Regards,
Kai
Replies to list-only preferred.
More information about the systemd-devel
mailing list