简体   繁体   中英

node.js memory leak with cluster and express

I am using the node.js 6.11.3 ,cluster module, express 4.14 Seeing memory leaks slowly over a period of 1 weeks. attached is a screenshot of the heap dumps in chrome dev tools. Cant tell the reason for the leak. click for heap dump

Unfortunately, nobody can answer where your leak comes from without accessing the entire application and environment. The real question is how do you debug a node memory leak.

First its important to try to understand how memory leaks occur in Node. How is it possible if Node has built in garbage collection? Well, variables are marked as garbage when no longer referenced. If you have code (closures etc) that still hold reference to variables, they are not collected. That is just one example. There are also dependencies that can cause memory leaks which can confuse you into thinking you have issues in your own code. And maybe you do, in the way you use the dependency.

Bottom line, its best to get familiar with this debugging process yourself so that you can understand the issues leading to the leak. Best of luck. Here is one article that is helpful.

https://www.alexkras.com/simple-guide-to-finding-a-javascript-memory-leak-in-node-js/

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