Skip to content

Instantly share code, notes, and snippets.

@Raynos
Forked from Matt-Esch/unref-leak.js
Created June 6, 2014 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/c9b67658a7b89bfe7484 to your computer and use it in GitHub Desktop.
Save Raynos/c9b67658a7b89bfe7484 to your computer and use it in GitHub Desktop.
var setTimeout = require('timers').setTimeout;
var work = 0;
console.log('version: ' + process.version);
if (typeof gc === 'undefined') {
throw new Error('run node foo.js --expose-gc');
}
setTimeout(function loop() {
gc();
var timer = setTimeout(function () {
work += 1;
loop();
}, 10);
timer.unref();
}, 10);
(function keepalive() {
setTimeout(function () { keepalive(); }, 1000000000);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment