From e96ce4e484b8b90b435e65a15c14df29c740a3df Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 17 Sep 2019 19:28:53 +0200 Subject: [PATCH] Memory Leak Bug Fixed --- Commons.js | 14 ++++++++++++-- Multi-Period/User.Bot.js | 11 ++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Commons.js b/Commons.js index 86c24b94e..66931e537 100644 --- a/Commons.js +++ b/Commons.js @@ -8,6 +8,7 @@ const GMT_SECONDS = ':00.000 GMT+0000'; let thisObject = { + finalize: finalize, runSimulation: runSimulation, buildPercentageBandwidthArray: buildPercentageBandwidthArray, buildBollingerBandsArray: buildBollingerBandsArray, @@ -28,6 +29,15 @@ return thisObject; + function finalize() { + percentageBandwidthAt = undefined + bollingerBandsAt = undefined + bollingerChannelsAt = undefined + bollingerSubChannelsAt = undefined + candlesAt = undefined + thisObject = undefined + } + async function runSimulation( timePeriod, timePeriodLabel, @@ -2735,8 +2745,8 @@ i++ if (i < candles.length) { - // process.nextTick(loop) - setTimeout(loop, 100) + process.nextTick(loop) + //setTimeout(loop, 100) } else { afterLoop() } diff --git a/Multi-Period/User.Bot.js b/Multi-Period/User.Bot.js index 7d818ef4e..95d9b8ba8 100644 --- a/Multi-Period/User.Bot.js +++ b/Multi-Period/User.Bot.js @@ -12,10 +12,11 @@ const ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000; - const commons = COMMONS.newCommons(bot, logger, UTILITIES); + let commons = COMMONS.newCommons(bot, logger, UTILITIES); thisObject = { initialize: initialize, + finalize: finalize, start: start }; @@ -44,6 +45,14 @@ } } + function finalize() { + commons.finalize() + commons = undefined + utilities = undefined + assistant = undefined + thisObject = undefined + } + function start(multiPeriodDataFiles, timePeriod, timePeriodLabel, currentDay, startDate, endDate, interExecutionMemory, callBackFunction) { try {