Hi! I'm Nathan Hoad


Memory Leak with Node.js on Heroku

If you are having issues with a Heroku based Node app consuming insane amounts of memory then chances are it's not your fault. Are you using New Relic for monitoring? Yes? Then it's probably that.

After noticing that each time I deployed one of my apps it would steadily consume all available memory my first thought was 'What did I change?' and hunted around for something I'd done that might have been the cause. A few hours of digging and Googling later I discovered that it was actually a common problem and that a load of other people had narrowed the cause down to the New Relic node module.

Sure enough, after commenting out my require('newrelic'); and leaving the app to sit for a while the memory problem was gone (Previous deploys reset the memory graph).

Heroku memory graph

New Relic do have a support page for the issue if you'd like to try out some of their suggestions (a few people have had success).

If I just made your day a little better then thank me with a coffee or maybe a a pizza