How to put a limit (Memory Max=) on a systemd service in a Raspberry Pi?

  • I have the same.

    I also clean all settings and start from fresh and still see memory line.

    Try adding line

    Code
    DefaultMemoryAccounting=yes

    or

    Code
    CPUAccounting = yes
    MemoryAccounting = yes
  • I have the same.

    I also clean all settings and start from fresh and still see memory line.

    Try adding line

    Code
    DefaultMemoryAccounting=yes

    or

    Code
    CPUAccounting = yes
    MemoryAccounting = yes

    After add, CPU: 233ms shows, but memory don't.

  • Because the system partition of LibreELEC is a read-only partition, which is for a good reason. LibreELEC is set up for use as a HTPC environment, it's not meant for the typical tweaking & fiddling IT tinkerer.

    You can edit things of you mount the partition as writeable first.

    Just know that all edits will be gone with the next LibreELEC downgrade/upgrade.

    How can I make it writable? To test this

    Code
    DefaultMemoryAccounting=yes
    CPUAccounting=yes
    MemoryAccounting=yes 

    there.

  • You can set parameters dynamically:

    Code
    systemctl set-property kodi CPUAccounting=yes
    systemctl set-property kodi BlockIOAccounting=no
    systemctl set-property kodi MemoryAccounting=yes
    systemctl set-property kodi MemoryMax=100M
    systemctl status kodi
  • You can set parameters dynamically:

    Code
    systemctl set-property kodi CPUAccounting=yes
    systemctl set-property kodi BlockIOAccounting=no
    systemctl set-property kodi MemoryAccounting=yes
    systemctl set-property kodi MemoryMax=100M
    systemctl status kodi

    This don't worked too :(

  • Ok, try adding cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 to /flash/config.txt (or wherever boot parameters are set). Reboot and check systemctl status of kodi or whatever service.

  • I will open a new thread specifically asking about how to put a limit (Memory Max=) in a systemd service in a Raspberry Pi.

    Thank you very much again for help me!

    Sorry, the page had not yet refresh when I posted it.

    vpeter  edjalmo

    It works, but you must add cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 at the end of /flash/cmdline.txt

    This is what systemctl status shows on my Pi:

    Code
    Main PID: 740 (sh)
    Memory: 55.5M (max: 250.0M)

    I added this and put MemoryMax=100M in the service, but it still does not show in status.

  • thoradia  vpeter

    Code
    mount -o remount,rw /flash
    /flash/cmdline.txt
    Put cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 inside
    Open jackett service
    Put MemoryMax=100M inside
    Do systemctl daemon-reload
    reboot the system

    I'm doing something wrong?

    Why is not working? :(

  • Worked!!!

    When you said

    at the end of /flash/cmdline.txt

    I thought it was to put in the line below, as this did not work. Today I add cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 in the end of the line that already exists. So, staying that way

    Code
    boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1

    and worked! :)

    Thank you very much thoradia and vpeter :)