segmentio / nsq.js

NSQ client for nodejs
203 stars 34 forks source link

Memory leak caused by setInterval #66

Open poying opened 9 years ago

poying commented 9 years ago

It seems hardly to resolve this problem in normal way, but node-sleep + child_process may be an alternative solution.

// timer.js
var sleep = require('sleep').sleep;
while (1) {
  sleep(1);
  process.send('tick');
}

// reader.js
this.timer = child_process.fork('./timer');
this.timer.on('message', function (msg) {
  // poll
});