From c4ca46610d5cfa335aea2789508ce620bbede539 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 5 Jul 2013 23:08:59 +0800 Subject: [PATCH] force gc --- bin/sslocal | 4 ++-- bin/ssserver | 4 ++-- lib/shadowsocks/utils.js | 7 +++++++ src/utils.coffee | 6 ++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/sslocal b/bin/sslocal index 0aa5753..9cbd5b8 100755 --- a/bin/sslocal +++ b/bin/sslocal @@ -1,7 +1,7 @@ -#!/usr/bin/env node +#!/usr/bin/env node --expose-gc var path = require('path'); var fs = require('fs'); var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); -require(lib + '/shadowsocks/local').main() \ No newline at end of file +require(lib + '/shadowsocks/local').main() diff --git a/bin/ssserver b/bin/ssserver index 8f50b12..142295c 100755 --- a/bin/ssserver +++ b/bin/ssserver @@ -1,7 +1,7 @@ -#!/usr/bin/env node +#!/usr/bin/env node --expose-gc var path = require('path'); var fs = require('fs'); var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); -require(lib + '/shadowsocks/server').main() \ No newline at end of file +require(lib + '/shadowsocks/server').main() diff --git a/lib/shadowsocks/utils.js b/lib/shadowsocks/utils.js index 6a0c5ba..ab5a550 100644 --- a/lib/shadowsocks/utils.js +++ b/lib/shadowsocks/utils.js @@ -84,4 +84,11 @@ return exports.log(exports.ERROR, msg); }; + setInterval(function() { + if (global.gc) { + exports.debug('GC'); + return gc(); + } + }, 1000); + }).call(this); diff --git a/src/utils.coffee b/src/utils.coffee index 8b570b0..b08740b 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -59,3 +59,9 @@ exports.warn = (msg)-> exports.error = (msg)-> exports.log exports.ERROR, msg + +setInterval(-> + if global.gc + exports.debug 'GC' + gc() +, 1000)