NodeJS / ExpressJS memory leak

I have a static ExpressJS server:

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

When I start the server, it uses a 20 MB v8 heap. If I reload the page every second, the heap is used constantly. After 4 hours, he goes to the 40 MB heap v8. The total v8 heap reaches 80 MB, and RSS (shared memory used by the process) reaches up to 130 MB.

Why does this simple and static server use so much bar? There seems to be a memory leak. If I do not stop reloading the page, the used memory continues to grow.

It is not possible to do large projects if a simple static server like this uses too much bar.

NodeJS Version: v0.10.21 ExpressJS Version: 3.3.5

EDIT: I noticed that this is a problem with NodeJS because I tried node-static instead of expression, and while the used / shared heap of V8 remained constant, the RSS memory used by nodejs continued to grow.

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)

+6
source share
1 answer

Not sure if you still need an answer, but a bad post for everyone who might have the same problems.

I had the exact same problem and fixed it with:

 --max-old-space-size 5 

This limits the amount of memory until it is deleted by the GC.

+3
source

All Articles