Categories
express javascript memory-leaks node.js

Does Express.js on Node.js have a memory leak?

I have been using express on node.js running on a heroku server for a simple project. When I started using new relic to monitor the memory I noticed a slow memory leak pattern. I removed all the code I developed and all other node modules and left only express itself and new relic modules. I still observe the memory leak.
I was wondering if this is express.js memory leak.
Here is the graphic from new relic

Here is all the code left:

require('newrelic');
var express = require('express');
var app = express();
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
app.set('port', process.env.PORT || 3000);
}
app.get('/', function ( req, res ) {
res.send('The server is up and running!');
});
app.listen(app.get('port'), function() {
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});

And package.json

{
"name": "memleakdebug",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.11.2",
"newrelic": "^1.16.2"
}
}

UPDATE1: Now growing memory even passed heroku’s limit 512MB for free tiers.
Garbage collection doesn’t seem to work.

Memory keeps growing