I'm using Arch Linux and systemd version is 239. I booted system with systemd.unified_cgroup_hierarchy=1 kernel parameter.
I made two unit files, limit.slice and malloc.service.
[Unit] Description=limit memory slice. [Slice] MemoryAccounting=yes MemoryMax=100M
and malloc.service is
[Unit] Description=memory consuming process [Service] ExecStart=/home/example/malloc_program Slice=limit.slice
malloc_program is just keep calls malloc() to consume memory.
I put these files to /home/example/.config/systemd/user/ and run
systemctl --user start malloc.service.
Service's CGroup is under
limit.slice as expected.
But, the process keeps running even when the used memory was over 100 MB.
I can't understand why memory limitation is not working in user instance...