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
    1. DefaultMemoryAccounting=yes

    or

    Code
    1. CPUAccounting = yes
    2. MemoryAccounting = yes

    Gone...

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

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • My hardware is a Raspberry Pi 3b, your is the same?

    But this don't interfere in anything, right?

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • 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
    1. DefaultMemoryAccounting=yes
    2. CPUAccounting=yes
    3. MemoryAccounting=yes 

    there.

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • You can set parameters dynamically:

    Code
    1. systemctl set-property kodi CPUAccounting=yes
    2. systemctl set-property kodi BlockIOAccounting=no
    3. systemctl set-property kodi MemoryAccounting=yes
    4. systemctl set-property kodi MemoryMax=100M
    5. systemctl status kodi

    Gone...

  • You can set parameters dynamically:

    Code
    1. systemctl set-property kodi CPUAccounting=yes
    2. systemctl set-property kodi BlockIOAccounting=no
    3. systemctl set-property kodi MemoryAccounting=yes
    4. systemctl set-property kodi MemoryMax=100M
    5. systemctl status kodi

    This don't worked too :(

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • I installed LE on another sd card and it's the same. I'm starting to think it's because I use in RPi version.

    @Klojum , Can you help me?

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

    Edited once, last by edjalmo ().

  • Must be RPi difference then. Maybe some kernel config... Some CGROUP or MEMCG parameter.

    Anyway, thank you very much for trying to help!

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • 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.

    Gone...

  • I added, but don't worked too :(

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • 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
    1. Main PID: 740 (sh)
    2. Memory: 55.5M (max: 250.0M)

    Keep it legal and carry on

  • 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!

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • 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
    1. Main PID: 740 (sh)
    2. Memory: 55.5M (max: 250.0M)

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

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • thoradia  vpeter


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

    I'm doing something wrong?

    Why is not working? :(

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • edjalmo

    Changed the title of the thread from “How can I edit /etc/systemd/system.conf?” to “How to put a limit (Memory Max=) on a systemd service in a Raspberry Pi?”.
  • 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
    1. 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 :)

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b