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)
Not sure if you are still in need of an answer but ill post for anyone else who might be having the same issues.
I was having this same exact problem and fixed it by using:
--max-old-space-size 5
This limits how much memory is held until it gets deleted by GC.
To help the creators of NodeJS and Express potentially, try taking memory snapshots (done using chrome dev tools, use the url chrome://inspect ) this will allow you to see where your memory is allocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With