node-memwatch icon indicating copy to clipboard operation
node-memwatch copied to clipboard

Sending STOP and CONT signals to a process triggers continuous "stats" event

Open strk opened this issue 12 years ago • 0 comments

When memwatch.HeapDiff is used from within the 'stats' handler, and the process is sent a STOP followed by a CONT signal, an infinite loop of 'stats' events is sent.

Here's the code:

memwatch.on('leak', function(info) {
  console.log("Leak detected by memwatch");
  console.dir(info);
});

var hd = new memwatch.HeapDiff();

memwatch.on('stats', function(stats) {
  console.log("Memwatch stats");
  console.dir(stats);

  var diff = hd.end();

  console.log("HeapDiff:");
  console.dir(diff.change);
  console.dir(diff.details);

  hd = new memwatch.HeapDiff();
});

strk avatar Feb 05 '13 16:02 strk