4
아래 코드를 실행하여 서버를 다시 시작하면 uncaughtException이 하나 이상 발생하지만 더 이상 오류가 없으면 메모리가 매우 빠르게 증가합니다. 이 문제를 해결하는 이유와 방법을 알고 싶습니다. 이 offline_queue
을의에재발행을 다시 시작할 때 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);
})