Categories
express memory memory-leaks node.js

NodeJS / ExpressJS Memory Leak

I’ve a static ExpressJS Server like that:

var express = require("express"),
app = express();
app.use(express.static(__dirname));
app.listen(1050);

When i start the server it uses 20MB of v8 heap. If i do a page reload every second the heap used grow continuously. After 4 hours it goes to 40MB of v8 heap used. The total v8 heap goes to 80MB and the RSS (total memory used by the process) goes to 130MB.

Why this simple and static server uses so much ram? It seems a memory leak. If i don’t stop the page reload, the used memory keeps growing.

It’s impossible to do larger projects if a simple static server like this uses too much ram.

NodeJS version: v0.10.21
ExpressJS version: 3.3.5

EDIT: I noticed that it’s a problem with NodeJS, because i tried node-static instead of express, and while the used/total V8 heap stayed constant, the RSS memory used by nodejs continued to grow up.

Screen:

https://www.dropbox.com/s/4j5qs3rv2549dix/Screenshot%202014-03-20%2014.06.57.png
https://www.dropbox.com/s/0c30ou8l3rv2081/Screenshot%202014-03-20%2014.07.54.png
https://www.dropbox.com/s/5be1isk4v70qj8g/Screenshot%202014-03-20%2014.08.10.png

(Starts at 13:48)