How to list systemd services by memory usage

Solution 1:

Enable memory accounting by creating /etc/systemd/system.conf.d/accounting.conf containing

[Manager]
#DefaultCPUAccounting=yes
#DefaultBlockIOAccounting=yes
DefaultMemoryAccounting=yes
#DefaultTasksAccounting=yes

Reload after config change.

systemctl daemon-reload

Watch units (cgroups) by memory size.

systemd-cgtop -m