Memory leaks in Node
Wednesday, December 2, 2015 by Dave Winer

I have a Node.js question today, regarding memory leaks.

I have a Ubuntu machine on EC2 with 18 processes running in forever

One of the processes produces a server log that shows the amount of memory available. When it started, a bit over 24 hours ago, it showed there was over 800MB of memory free. Now it's showing 450MB free. 

The number fluctuates, but the trend clearly is down.

Restarting the app doesn't change the amount of free memory, which was a surprise. If there was a memory leak I would expect this number would immediately go back to 800MB.

Perhaps there is a leak in one of the other 17 processes?

I have no experience debugging memory leaks in Node, though I have a lot of experience with it in other environments. 

I'm wondering how people approach debugging JavaScript memory leaks? Is it something to worry about? I imagine bad things will happen if this number were to hit zero.

If you have an idea, please post a comment

  • This article (http://blog.yld.io/2015/08/10/debugging-memory-leaks-in-node-js-a-walkthrough/) has an up-to-date walkthrough for doing this in a node app. One thing I'll add is that New Relic has a fantastic service for monitoring and giving analytics for your apps in production. Now, they're pricy -- but they offer a 14-day free trial. (http://newrelic.com/application-monitoring/features)

  • This is from Netflix on how they debug Node.js memory leaks (in the second half of the video) http://techblog.netflix.com/2015/12/debugging-nodejs-in-production.html?m=1