Skip to content

perf(memory): run under jemalloc to bound RSS - #275

Merged
dfguerrerom merged 1 commit into
mainfrom
perf/jemalloc-memory
Jul 3, 2026
Merged

perf(memory): run under jemalloc to bound RSS#275
dfguerrerom merged 1 commit into
mainfrom
perf/jemalloc-memory

Conversation

@dfguerrerom

Copy link
Copy Markdown
Collaborator

Run the container process under jemalloc so freed per-session memory is returned to the OS.

Problem: glibc/pymalloc never release the arenas fragmented by per-session widget churn, so RSS ratchets to the peak concurrent working set and stays there until restart — the production OOM.

Fix: preload libjemalloc (PYTHONMALLOC=malloc, decay-based page purge) so memory follows users back down. Replaces the earlier MALLOC_ARENA_MAX mitigation.

The ENV is placed after the build layers so image builds don't run under the preload. Verify after any image change:

grep -c jemalloc /proc/<solara-python-pid>/maps   # >= 1

Preload libjemalloc and set PYTHONMALLOC=malloc so freed per-session
pages are returned to the OS via madvise decay, instead of glibc/pymalloc
ratcheting RSS to the peak concurrent working set. Replaces the earlier
MALLOC_ARENA_MAX mitigation.
@dfguerrerom
dfguerrerom merged commit 6b6e7cc into main Jul 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant