First I tought something is wrong with my node.js modules or codes because as I visited my pages the memory decreased after every visit and it was not released back. After hours of debugging, I couldn't find any problem, so I tried the default node.js server example to see if the problem is in my code or in node.js itself.
So I created the server like this:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(80);
console.log('Server running at port 80');
I visited mydomain.com and hit refresh repeatedly, and the free memory just kept dropping, and even after I release the refreshing, the memory remains at the same level, so node.js keeps it.
Environment
I was testing on ubuntu 12, max os x 10.8.3 with node v0.9.0, node v0.10.0, v0.10.2, v0.10.4, v0.11.1 where the problem exists and on node v0.8.21 where it works properly, that's why I say it maybe be a bug in newer versions.
V8 will call GC when needed and the memory usage should be decreased at that point.
To make sure that the GC process is working fine, I suggest you to run node with --expose-gc argument and check the memory usage with something like this:
var http = require('http'),
util = require('util');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
global.gc();
console.log('Memory Usage:');
console.log(util.inspect(process.memoryUsage()));
}).listen(8080); // changed the port to 8080 because I didn't want to run the server as root
console.log('Server running at port 8080');