How to change memory allocator for a container? (sharp package memory leak)
Hi, i am using sharp node package to convert images for my project but it seems that container ram memory increase with every convert request. The suggestion is to use another allocator (jemalloc) but i dont know how (and where) can i put this command before service start up?
I am guessing that his has to do with something about dockerfile but i am not a docker guy.
RUN apt-get update && apt-get install --force-yes -yy \
libjemalloc1 \
&& rm -rf /var/lib/apt/lists/*
# Change memory allocator to avoid leaks
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
Solution:Jump to solution
these are things you'd want to do with a Dockerfile for sure, there are tons of great resources on dockerfiles all over the internet!
9 Replies
Project ID:
195c8de3-388a-4048-9e0c-20a277092626
195c8de3-388a-4048-9e0c-20a277092626
Solution
these are things you'd want to do with a Dockerfile for sure, there are tons of great resources on dockerfiles all over the internet!
If i write docker file with just those commands will it just merge with default railway build?
no, you need to write the entire dockerfile
Is there a default dockefile from railway so i can edit it?
there isnt, as thats not quite how railway works
In case someone find this thread i fixed this problem using my own docker container (instead of default railway's) without changing the allocator, based on alpine linux. Because i developed in node 18, my image of choice was node:18-alpine3.18. No problem with allocation and deallocation so far:
awesome, glad to hear