From 8ca9c5bcf77fec999daefcd2f803163ecbb3eea2 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 29 Mar 2017 15:56:30 +0200 Subject: [PATCH] Active GC interval Interval timer is configurable, disabling by using <=0 value. --- app.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app.js b/app.js index f6692d36..1220e8f6 100755 --- a/app.js +++ b/app.js @@ -136,3 +136,17 @@ process.on('SIGHUP', function() { process.on('uncaughtException', function(err) { global.logger.error('Uncaught exception: ' + err.stack); }); + +if (global.gc) { + var gcInterval = Number.isFinite(global.environment.gc_interval) ? + global.environment.gc_interval : + 10000; + + if (gcInterval > 0) { + setInterval(function gcForcedCycle() { + var start = Date.now(); + global.gc(); + global.statsClient.timing('windshaft.gc', Date.now() - start); + }, gcInterval); + } +}