Skip to content

Commit afc163d

Browse files
Bo-Onyxjustin-tahara
authored andcommitted
fix(api memory): replace glibc with jemalloc for memory allocating (#9196)
1 parent 0f214ca commit afc163d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

backend/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ RUN apt-get update && \
4242
pkg-config \
4343
gcc \
4444
nano \
45-
vim && \
45+
vim \
46+
libjemalloc2 \
47+
&& \
4648
rm -rf /var/lib/apt/lists/* && \
4749
apt-get clean
4850

@@ -124,6 +126,13 @@ ENV PYTHONPATH=/app
124126
ARG ONYX_VERSION=0.0.0-dev
125127
ENV ONYX_VERSION=${ONYX_VERSION}
126128

129+
# Use jemalloc instead of glibc malloc to reduce memory fragmentation
130+
# in long-running Python processes (API server, Celery workers).
131+
# The soname is architecture-independent; the dynamic linker resolves
132+
# the correct path from standard library directories.
133+
# Placed after all RUN steps so build-time processes are unaffected.
134+
ENV LD_PRELOAD=libjemalloc.so.2
135+
127136
# Default command which does nothing
128137
# This container is used by api server and background which specify their own CMD
129138
CMD ["tail", "-f", "/dev/null"]

0 commit comments

Comments
 (0)