From 03f67deb89a0784eea2623ac87044a1d70ba2c69 Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Tue, 1 Aug 2023 19:40:26 +0200 Subject: [PATCH] clear hep memory --- electron.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/electron.js b/electron.js index 7190f5c3..18851006 100644 --- a/electron.js +++ b/electron.js @@ -41,19 +41,16 @@ crashReporter.start({ uploadToServer: false }) -if (myMemory > 16000000000) { - app.commandLine.appendSwitch('js-flags', '--max-old-space-size=8192') - log.info("Memory Size Is 16GB Using JS Memory Heap Size 8GB") -} else if (myMemory > 12000000000) { - app.commandLine.appendSwitch('js-flags', '--max-old-space-size=6144') - log.info("Memory Size Is 12GB Using JS Memory Heap Size 6GB") -} else if (myMemory > 7000000000) { - app.commandLine.appendSwitch('js-flags', '--max-old-space-size=4096') - log.info("Memory Size Is 8GB Using JS Memory Heap Size 4GB") -} else { - app.commandLine.appendSwitch('js-flags', '--max-old-space-size=2048') - log.info("Memory Size Is 4GB Using JS Memory Heap Size 2GB") -} +app.commandLine.appendSwitch('js-flags', '--max-executable-size=192 --max-old-space-size=1024 --max-semi-space-size=2') + +setInterval (function() { + let mu = process.memoryUsage() + log.info('heapTotal:', mu.heapTotal, 'heapUsed:', mu.heapUsed); + if (mu.heapUsed > 1024 * 1024 * 1024) { + log.info('Taking out the garbage') + global.gc() + } +}, 1000 * 120) if (process.arch === 'arm') { app.disableHardwareAcceleration()