R
Railway10mo 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
Percy10mo ago
Project ID: 195c8de3-388a-4048-9e0c-20a277092626
lowzyyy
lowzyyyOP10mo ago
195c8de3-388a-4048-9e0c-20a277092626
Solution
Brody
Brody10mo 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
lowzyyyOP10mo ago
If i write docker file with just those commands will it just merge with default railway build?
Brody
Brody10mo ago
no, you need to write the entire dockerfile
lowzyyy
lowzyyyOP10mo ago
Is there a default dockefile from railway so i can edit it?
Brody
Brody10mo ago
there isnt, as thats not quite how railway works
lowzyyy
lowzyyyOP10mo 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
Brody10mo ago
awesome, glad to hear
Want results from more Discord servers?
Add your server