From 45fdeaec5a9c06381f648988b953fcd17bf1eb8b Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Wed, 8 Apr 2015 12:51:31 -0500 Subject: [PATCH] Revert "Revert "Add some (belated) memory watching"" This reverts commit d015e8f79041348b9f3911cf9f01d4d16e6559f3, reinstating the memory stuff. --- app.js | 50 +++++++++++++++++++++++++------------------------- lib/compile.js | 2 +- package.json | 1 + 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app.js b/app.js index 34a72376..1382d353 100755 --- a/app.js +++ b/app.js @@ -36,12 +36,12 @@ var nopt = require('nopt'), Promise = require('promise'), memwatch = require('memwatch'); -memwatch.on('leak', function(info){ - console.log("Memwatch leak: " + info); +memwatch.on('leak', function (info) { + console.log("Memwatch leak: " + JSON.stringify(info)); }); -memwatch.on('stats', function(stats){ - console.log("Memwatch stats: " + info); +memwatch.on('stats', function (stats) { + console.log("Memwatch stats: " + JSON.stringify(stats)); }); var opts = nopt({ @@ -195,29 +195,29 @@ function configuredCompilers() { var port = parseInt(bits[1]); console.log("Fetching compilers from remote source " + host + ":" + port); return retryPromise(function () { - return new Promise(function (resolve, reject) { - http.get({ - hostname: host, - port: port, - path: "/api/compilers" - }, function (res) { - var str = ''; - res.on('data', function (chunk) { - str += chunk; - }); - res.on('end', function () { - var compilers = JSON.parse(str).map(function (compiler) { - compiler.exe = null; - compiler.remote = "http://" + host + ":" + port; - return compiler; + return new Promise(function (resolve, reject) { + http.get({ + hostname: host, + port: port, + path: "/api/compilers" + }, function (res) { + var str = ''; + res.on('data', function (chunk) { + str += chunk; + }); + res.on('end', function () { + var compilers = JSON.parse(str).map(function (compiler) { + compiler.exe = null; + compiler.remote = "http://" + host + ":" + port; + return compiler; + }); + resolve(compilers); }); - resolve(compilers); + }).on('error', function (e) { + reject(e); }); - }).on('error', function (e) { - reject(e); }); - }); - }, + }, host + ":" + port, props.get('gcc-explorer', 'proxyRetries', 20), props.get('gcc-explorer', 'proxyRetryMs', 500)); @@ -263,7 +263,7 @@ function getCompilerInfo(compilerInfo) { }); } if (options['-masm']) { - compilerInfo.intelAsm="-masm=intel"; + compilerInfo.intelAsm = "-masm=intel"; } resolve(compilerInfo); }); diff --git a/lib/compile.js b/lib/compile.js index 02549d1a..437b5ebe 100644 --- a/lib/compile.js +++ b/lib/compile.js @@ -46,7 +46,7 @@ function Compile(compilers) { this.cache = LRU({ max: props.get('gcc-explorer', 'cacheMb') * 1024 * 1024, length: function (n) { - return n.length; + return n.asm.length; } }); this.cacheHits = 0; diff --git a/package.json b/package.json index 6ac2f37e..78cc7771 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "fs-extra": "0.8.x", "http-proxy": "1.8.x", "lru-cache": "2.5.x", + "memwatch": "0.2.x", "morgan": "1.5.x", "promise": "6.1.x", "promise-queue": "2.1.x",