我的代码正在泄漏内存。几个小时后,它会填满整个内存并崩溃。我在这里简化了我的代码,有人能判断这是否看起来像泄漏吗?谢谢。
var request = require('request').forever(), // as per [1]
async = require('async'),
kue = require('kue'),
jobs = kue.createQueue(),
pool = { maxSockets: 1 };
function main (job, done) {
async.series(
[function (callback) {
var req = request({url: job.data.URL1, pool: pool}, function (err, resp, body) {
//stuff...
callback(err);
});
},
function (callback) {
var req = request({url: job.data.URL2}, function (err, resp, body) {
//stuff...
callback(err);
});
}
],
function (err) {
//stuff...
done();
}
);
}
jobs.process('job_name', function (job, done) { //many jobs with 'job_name' in the queue
main (job, done);
});
[1] https://groups.google.com/d/msg/nodejs/ZI6WnDgwwV0/sFm4QKK7ODEJ