var connect = require('connect'),
app = connect();
app.use(connectRoute(function (router) {
router.get('/', function (req, res, next) {
callFun(res);
})
}))
app.listen(port);
/** callFun **/
function callFun(res) {
var http = require('http');
var req = http.request(options, function(response) {
response.on('data', function (chunk) {
res.end(chunk);
});
});
}
当我尝试使用nodeload
运行上述代码时
./nl.js -c 1 -n 10 -i 1 http://localhost:1000/
我收到以下警告
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Socket.EventEmitter.addListener (events.js:160:15)
at Socket.Readable.on (_stream_readable.js:663:33)
at ClientRequest.<anonymous> (http.js:2069:7)
at ClientRequest.EventEmitter.emit (events.js:117:20)
at http.js:1710:9
at process._tickCallback (node.js:415:13)
如何解决此问题?
对此有任何帮助将非常有帮助。感谢
答案 0 :(得分:0)
该警告由nodeload
生成,而不是由您的应用生成。
运行nodeload
时,我还会收到其他警告:
http.createClient is deprecated. Use `http.request` instead.
我猜测nodeload
已达到EOL是公平的,也许你应该开始寻找替代品(我喜欢flod)。或者只是将警告视为理所当然,因为nodeload
仍然可以正常工作。