Skip to content

Instantly share code, notes, and snippets.

@prabhakhar
Created June 21, 2012 01:13
Show Gist options
  • Save prabhakhar/2963290 to your computer and use it in GitHub Desktop.
Save prabhakhar/2963290 to your computer and use it in GitHub Desktop.
Possible EventEmitter memory leak detected.
var http = require('http');
var options = {
host : 'www.nodejs.org',
port : 80,
method : 'HEAD',
path : '/api/http.html'
};
for( var i = 0 ; i < 10000 ; ++i ) {
var req = http.request(options, function(res) {
});
req.setTimeout(600, function() {
console.log('timed out');
});
req.end();
}
@s3u
Copy link

s3u commented Jun 22, 2012

See https://gist.github.com/2973367 for a variant of the test. The leak warning comes up when a new request is created using a socket that has outstanding requests. You can verify this by setting the agent to false in which case the socket has no outstanding requests. This explains why this warning comes up under load with the default agent.

See https://gist.github.com/joyent/node/blob/v0.6.19-release/lib/net.js#L143.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment