104
submitted 1 year ago* (last edited 1 year ago) by American_Jesus@lemm.ee to c/selfhosted@lemmy.world

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_

you are viewing a single comment's thread
view the rest of the comments
[-] enemenemu@lemm.ee 17 points 1 year ago
[-] American_Jesus@lemm.ee 23 points 1 year ago

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.
this post was submitted on 31 Mar 2025
104 points (92.6% liked)

Selfhosted

61770 readers
303 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 3 years ago
MODERATORS