do_nothing_server.js 423 B

1234567891011121314151617
  1. // a trivial process that does nothing except
  2. // trigger GC and output the present base memory
  3. // usage every second. this example is intended to
  4. // demonstrate that memwatch itself does not leak.
  5. var memwatch = require('../');
  6. memwatch.on('gc', function(d) {
  7. if (d.compacted) {
  8. console.log('current base memory usage:', memwatch.stats().current_base);
  9. }
  10. });
  11. setInterval(function() {
  12. memwatch.gc();
  13. }, 1000);