Skip to content
Permalink
Browse files

working on #133

  • Loading branch information...
janoside committed Oct 1, 2019
1 parent 0fd7214 commit a6e7bea9ee415b9fbc0d845b13f73042de671364
Showing with 38 additions and 1 deletion.
  1. +22 −1 app/utils.js
  2. +15 −0 npm-shrinkwrap.json
  3. +1 −0 package.json
@@ -11,6 +11,7 @@ var config = require("./config.js");
var coins = require("./coins.js");
var coinConfig = coins[config.coin];
var redisCache = require("./redisCache.js");
var heapdump = require("heapdump");


var exponentScales = [
@@ -229,14 +230,34 @@ function ellipsize(str, length) {
}
}

global.lastHeapdump = -1;
function logMemoryUsage() {
var mbUsed = process.memoryUsage().heapUsed / 1024 / 1024;
mbUsed = Math.round(mbUsed * 100) / 100;

var mbTotal = process.memoryUsage().heapTotal / 1024 / 1024;
mbTotal = Math.round(mbTotal * 100) / 100;

//debugLog("memoryUsage: heapUsed=" + mbUsed + ", heapTotal=" + mbTotal + ", ratio=" + parseInt(mbUsed / mbTotal * 100));
if (global.gc) {
debugLog("Forcing garbage collection...");

global.gc();
}

debugLog("MemoryUsage: heapUsed=" + mbUsed + ", heapTotal=" + mbTotal + ", ratio=" + parseInt(mbUsed / mbTotal * 100));

var minutesBetweenHeapdumps = 10;
if (Date.now() - global.lastHeapdump > minutesBetweenHeapdumps * 60000) {
global.lastHeapdump = Date.now();

heapdump.writeSnapshot(function(err, filename) {
if (err != null) {
debugErrorLog(`Heapdump error: ${err}`);
}

debugLog(`Heapdump written to: ${filename}`);
});
}
}

function getMinerFromCoinbaseTx(tx) {

Some generated files are not rendered by default. Learn more.

@@ -34,6 +34,7 @@
"electrum-client": "github:chaintools/node-electrum-client#43a999036f9c5",
"express": "^4.17.1",
"express-session": "1.16.1",
"heapdump": "0.3.15",
"jstransformer-markdown-it": "^2.1.0",
"lru-cache": "5.1.1",
"meow": "^5.0.0",

0 comments on commit a6e7bea

Please sign in to comment.
You can’t perform that action at this time.