简体   繁体   中英

Debugging memory leak in express application

I have a memory leak in my express application. The RSS memory starts at around 80Mb and grows slowly over time to reach around 2-3Gb over a couple of days. I have tried using the --inspect flag to start the process and debug in chrome inspector but not able to find out the exact issue. The Object allocation over a period of time is not that high in this case. The highest memory consumption is by strings as one can see in the attached screenshot. Can anyone point me in the right direction to fix this leak? 在此处输入图像描述

I have also attached the RSS graph. The decline in memory is due to shutting down the server. 在此处输入图像描述

Platform: Linux - Ubuntu 18.04.5

Well, it was a native module sharp leaking memory. It's being used in the application for image processing. We need to run the application with libjemalloc which works better with freeing the unused memory back to the OS. We can set the memory allocator by using the following command:

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM