Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Selfhosted
  3. PSA: If your Jellyfin is having high memory usage, add MALLOC_TRIM_THRESHOLD_=100000 to environment

PSA: If your Jellyfin is having high memory usage, add MALLOC_TRIM_THRESHOLD_=100000 to environment

Scheduled Pinned Locked Moved Selfhosted
selfhosted
16 Posts 12 Posters 26 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • american_jesus@lemm.eeA This user is from outside of this forum
    american_jesus@lemm.eeA This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1

    Many users reported high memory/RAM usage, some 8GB+.

    In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

    Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

    With Docker:
    Add to your docker-compose.yml and docker compose down && docker compose up -d

    ...
    environment:
      - MALLOC_TRIM_THRESHOLD_=100000
    ...
    

    With systemd:
    Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

    # Disable glibc dynamic heap adjustment
    MALLOC_TRIM_THRESHOLD_=100000
    

    Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

    Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
    Not present on some docker images like linuxserver/jellyfin

    Check is container (already) have the variable
    docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

    PS: Reddit doesn't allow edit post titles, needed to repost

    E B L A A 7 Replies Last reply
    1
    0
    • System shared this topic on
    • american_jesus@lemm.eeA [email protected]

      Many users reported high memory/RAM usage, some 8GB+.

      In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

      Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

      With Docker:
      Add to your docker-compose.yml and docker compose down && docker compose up -d

      ...
      environment:
        - MALLOC_TRIM_THRESHOLD_=100000
      ...
      

      With systemd:
      Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

      # Disable glibc dynamic heap adjustment
      MALLOC_TRIM_THRESHOLD_=100000
      

      Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

      Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
      Not present on some docker images like linuxserver/jellyfin

      Check is container (already) have the variable
      docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

      PS: Reddit doesn't allow edit post titles, needed to repost

      E This user is from outside of this forum
      E This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      What does it do?

      american_jesus@lemm.eeA 1 Reply Last reply
      0
      • E [email protected]

        What does it do?

        american_jesus@lemm.eeA This user is from outside of this forum
        american_jesus@lemm.eeA This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        The value of this tunable is the minimum size (in bytes) of the top-most, releasable chunk in an arena that will trigger a system call in order to return memory to the system from that arena.

        https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html


        MALLOC_MMAP_THRESHOLD_ is an environment variable that sets the size threshold for using the mmap system call to allocate memory instead of using the heap.

        • Default: 128 KiB
        • Behavior:
          • If a memory request is ≥ 128 KiB, mmap is used.
          • If < 128 KiB, the heap is used.
        • Purpose:
          • Helps manage large memory allocations more efficiently.
          • Can be adjusted to optimize performance for specific applications.
        1 Reply Last reply
        0
        • american_jesus@lemm.eeA [email protected]

          Many users reported high memory/RAM usage, some 8GB+.

          In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

          Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

          With Docker:
          Add to your docker-compose.yml and docker compose down && docker compose up -d

          ...
          environment:
            - MALLOC_TRIM_THRESHOLD_=100000
          ...
          

          With systemd:
          Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

          # Disable glibc dynamic heap adjustment
          MALLOC_TRIM_THRESHOLD_=100000
          

          Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

          Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
          Not present on some docker images like linuxserver/jellyfin

          Check is container (already) have the variable
          docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

          PS: Reddit doesn't allow edit post titles, needed to repost

          B This user is from outside of this forum
          B This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          What's the default value?

          american_jesus@lemm.eeA 1 Reply Last reply
          0
          • american_jesus@lemm.eeA [email protected]

            Many users reported high memory/RAM usage, some 8GB+.

            In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

            Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

            With Docker:
            Add to your docker-compose.yml and docker compose down && docker compose up -d

            ...
            environment:
              - MALLOC_TRIM_THRESHOLD_=100000
            ...
            

            With systemd:
            Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

            # Disable glibc dynamic heap adjustment
            MALLOC_TRIM_THRESHOLD_=100000
            

            Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

            Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
            Not present on some docker images like linuxserver/jellyfin

            Check is container (already) have the variable
            docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

            PS: Reddit doesn't allow edit post titles, needed to repost

            L This user is from outside of this forum
            L This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            PS: Reddit doesn't allow edit post titles, needed to repost

            But this is Lemmy.

            F 1 Reply Last reply
            0
            • L [email protected]

              PS: Reddit doesn't allow edit post titles, needed to repost

              But this is Lemmy.

              F This user is from outside of this forum
              F This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              OP didn't update their repost bot to understand what it's reposting.

              american_jesus@lemm.eeA 1 Reply Last reply
              0
              • american_jesus@lemm.eeA [email protected]

                Many users reported high memory/RAM usage, some 8GB+.

                In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

                Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

                With Docker:
                Add to your docker-compose.yml and docker compose down && docker compose up -d

                ...
                environment:
                  - MALLOC_TRIM_THRESHOLD_=100000
                ...
                

                With systemd:
                Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

                # Disable glibc dynamic heap adjustment
                MALLOC_TRIM_THRESHOLD_=100000
                

                Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

                Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
                Not present on some docker images like linuxserver/jellyfin

                Check is container (already) have the variable
                docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

                PS: Reddit doesn't allow edit post titles, needed to repost

                A This user is from outside of this forum
                A This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #7

                It's bad form to just say "set this variable to this value" without any explanation about what that variable does and why that value helped.

                Your configuration may not work or may be detrimental for others.

                T 1 Reply Last reply
                0
                • american_jesus@lemm.eeA [email protected]

                  Many users reported high memory/RAM usage, some 8GB+.

                  In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

                  Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

                  With Docker:
                  Add to your docker-compose.yml and docker compose down && docker compose up -d

                  ...
                  environment:
                    - MALLOC_TRIM_THRESHOLD_=100000
                  ...
                  

                  With systemd:
                  Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

                  # Disable glibc dynamic heap adjustment
                  MALLOC_TRIM_THRESHOLD_=100000
                  

                  Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

                  Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
                  Not present on some docker images like linuxserver/jellyfin

                  Check is container (already) have the variable
                  docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

                  PS: Reddit doesn't allow edit post titles, needed to repost

                  A This user is from outside of this forum
                  A This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #8

                  I've been having memory leak issues with my Jellyfin container, so I fired it up to see if it has a MALLOC variable set and it immediately crashed my server. Now waiting for the OOM killer to do its thing.

                  1 Reply Last reply
                  0
                  • A [email protected]

                    It's bad form to just say "set this variable to this value" without any explanation about what that variable does and why that value helped.

                    Your configuration may not work or may be detrimental for others.

                    T This user is from outside of this forum
                    T This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #9

                    If you click the source linked, you can read through all the details.

                    A 1 Reply Last reply
                    0
                    • american_jesus@lemm.eeA [email protected]

                      Many users reported high memory/RAM usage, some 8GB+.

                      In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

                      Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

                      With Docker:
                      Add to your docker-compose.yml and docker compose down && docker compose up -d

                      ...
                      environment:
                        - MALLOC_TRIM_THRESHOLD_=100000
                      ...
                      

                      With systemd:
                      Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

                      # Disable glibc dynamic heap adjustment
                      MALLOC_TRIM_THRESHOLD_=100000
                      

                      Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

                      Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
                      Not present on some docker images like linuxserver/jellyfin

                      Check is container (already) have the variable
                      docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

                      PS: Reddit doesn't allow edit post titles, needed to repost

                      T This user is from outside of this forum
                      T This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #10

                      Thank you for posting this! I've been increasing the memory for my VM over and over and it was using 24GB RAM + 4GB swap. Hopefully this will let me reclaim some.

                      1 Reply Last reply
                      0
                      • american_jesus@lemm.eeA [email protected]

                        Many users reported high memory/RAM usage, some 8GB+.

                        In my case gone from 1.5GB+ to 400MB or less on Raspberry Pi 4.

                        Adding MALLOC_TRIM_THRESHOLD_=100000can make a big difference.

                        With Docker:
                        Add to your docker-compose.yml and docker compose down && docker compose up -d

                        ...
                        environment:
                          - MALLOC_TRIM_THRESHOLD_=100000
                        ...
                        

                        With systemd:
                        Edit /etc/default/jellyfin change the value of MALLOC_TRIM_THRESHOLD_ and restart the service

                        # Disable glibc dynamic heap adjustment
                        MALLOC_TRIM_THRESHOLD_=100000
                        

                        Source: https://github.com/jellyfin/jellyfin/issues/6306#issuecomment-1774093928

                        Official docker,Debian,Fedora packages already contain MALLOC_TRIM_THRESHOLD_.
                        Not present on some docker images like linuxserver/jellyfin

                        Check is container (already) have the variable
                        docker exec -it jellyfin printenv | grep MALLOC_TRIM_THRESHO LD_

                        PS: Reddit doesn't allow edit post titles, needed to repost

                        B This user is from outside of this forum
                        B This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #11

                        How well does jellyfin work on a rpi? How many simultaneous 1080p users with AVC\ACC media can it do? Active cooling?

                        hiro8811@lemmy.worldH 1 Reply Last reply
                        0
                        • F [email protected]

                          OP didn't update their repost bot to understand what it's reposting.

                          american_jesus@lemm.eeA This user is from outside of this forum
                          american_jesus@lemm.eeA This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #12

                          Reddit people, should be banned

                          1 Reply Last reply
                          0
                          • B [email protected]

                            What's the default value?

                            american_jesus@lemm.eeA This user is from outside of this forum
                            american_jesus@lemm.eeA This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #13

                            It could depend on your distro, official packaging (docker,Debian,Fedora) have MALLOC_TRIM_THRESHOLD_=131072 , but different distros could have (or not) ship with different settings.

                            Official settings for systemd https://github.com/jellyfin/jellyfin-packaging/blob/master/debian/conf/jellyfin

                            1 Reply Last reply
                            0
                            • B [email protected]

                              How well does jellyfin work on a rpi? How many simultaneous 1080p users with AVC\ACC media can it do? Active cooling?

                              hiro8811@lemmy.worldH This user is from outside of this forum
                              hiro8811@lemmy.worldH This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #14

                              Didn't try but depends on which RPI. 4? 5?

                              S 1 Reply Last reply
                              0
                              • T [email protected]

                                If you click the source linked, you can read through all the details.

                                A This user is from outside of this forum
                                A This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #15

                                The linked source also doesn’t explain what the env variable actually does or why it fixes anything.

                                1 Reply Last reply
                                0
                                • hiro8811@lemmy.worldH [email protected]

                                  Didn't try but depends on which RPI. 4? 5?

                                  S This user is from outside of this forum
                                  S This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #16

                                  Also depends on the storage medium (SD? SSD?), assuming there's no transcoding.

                                  1 Reply Last reply
                                  0
                                  • System shared this topic on
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups