R
Railway6mo ago
lowzyyy

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:
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!
Jump to solution
9 Replies
Percy
Percy6mo ago
Project ID: 195c8de3-388a-4048-9e0c-20a277092626
lowzyyy
lowzyyy6mo ago
195c8de3-388a-4048-9e0c-20a277092626
Solution
Brody
Brody6mo ago
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!
lowzyyy
lowzyyy6mo ago
If i write docker file with just those commands will it just merge with default railway build?
Brody
Brody6mo ago
no, you need to write the entire dockerfile
lowzyyy
lowzyyy6mo ago
Is there a default dockefile from railway so i can edit it?
Brody
Brody6mo ago
there isnt, as thats not quite how railway works
lowzyyy
lowzyyy6mo ago
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:
No description
Brody
Brody6mo ago
awesome, glad to hear