joyent/node — Issue #1968: http requests consume lots of memory
Author: shtylman
Created: 2011-10-30 03:51:35+00:00
State: open

When making http requests to a node server, memory continues to be consumed and doesn't seem to be getting freed. I have the following code testcase:

var http = require('http');
var fs = require('fs');

var body = fs.readFileSync(__dirname + '/test.html');

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(body);
}).listen(1338, "127.0.0.1");

console.log('Server running at http://127.0.0.1:1337/');

function request() {
var options = {
host: 'localhost',
port: '1338',
path: '/',
};

var req = http.request(options, function(res) {
});

req.end();
console.log('RSS: ' + process.memoryUsage().rss);
};

setInterval(request, 100);

What I see is that RSS continues to grow over time. The test.html file I used was ~79K in size (needed something to make the test go faster but anything should do).

This was run on rev 6d7aa6539 (very recent from master).

I discovered this because I have a server making lots of requests (yes, not just being a server). And it's memory continues to grow over time and I can find no way to control the growth (making it look like a leak).