4
以下のコードを実行してサーバーを再起動すると、uncaughtExceptionが1つまたは2つありますが、もうエラーはなくなります。理由と方法を知りたい再起動時にnode.jsのメモリリークが発生する理由
/**
* This code will memory leak, if you restart redis server when the node process is running
*
* @author Gui Lin
*/
var redis = require('redis').createClient();
setInterval(function(){
redis.multi()
.zrangebyscore('timeup', 0, Date.now())
.zremrangebyscore('timeup', 0, Date.now())
.exec(function(err, data) {
if(err) console.log(err.stack);
if(data) data = data[0];
});
}, 1);
process.on('uncaughtException', function(err) {
console.log(err.stack);
})