[systemd-devel] MemoryLimit for user unit
WaLyong Cho
walyong.cho at samsung.com
Mon Nov 13 01:28:43 UTC 2017
On 2017년 11월 13일 09:53, Kai Krakow wrote:
> 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.
>
By this reason, MemorySwapMax= option is introduced.
https://github.com/systemd/systemd/pull/3659
Note, MemorySwapLimit= does not exist. Lennard does not want to add more
options for legacy cgroup. Further, the swap limit operations different
between legacy and unified cgroup. So adding MemorySwapLimit= was not
good idea.
>
>> 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...
>
>
More information about the systemd-devel
mailing list