How to make Jemalloc Work in NodeJS Server running on Heroku

410 views Asked by At

I am doing some image manipulation on the server side with a library called sharp. Unfortunately sharp is consuming so much memory during image transformation which ultimately leads to crashing the server every time. This is weird.

After several hours of digging,I was asked to add jemalloc heroku build pack to my buildpacks which I did using the command below:

heroku buildpacks:add --index 1 https://github.com/gaffneyc/heroku-buildpack-jemalloc.git

After which I deployed and restarted the server. Yet, the app is still crashing, so it seems Jemalloc is not yet activated.

Is there something else I can do to ensure Jemalloc is reducing the memory spike and prevent my server from constant crash?

Thank you

1

There are 1 answers

0
Nenad On

Just add jemalloc.sh before your script inside Procfile. Or set JEMALLOC_ENABLED variable to true.