Created
June 21, 2012 01:13
-
-
Save prabhakhar/2963290 to your computer and use it in GitHub Desktop.
Possible EventEmitter memory leak detected.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
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
I retract my first two comments.
http.request
returns a newClientRequest
each time -ClientRequest
is an EventEmitter - and hencetimeout
listeners don't pile up when a connection is reused.