From e6fef85128c3f3b784911643fc91dac63c3f3037 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Mon, 26 Mar 2018 20:57:51 +0900 Subject: [PATCH 1/2] Clear webFrame cache at a certain interval mattermost-webapp is SPA. So cache is not cleared due to no navigation. We needed to manually clear cache to free memory in long-term-use. --- src/browser/webview/mattermost.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/browser/webview/mattermost.js b/src/browser/webview/mattermost.js index 7b8398ee..7157407e 100644 --- a/src/browser/webview/mattermost.js +++ b/src/browser/webview/mattermost.js @@ -7,6 +7,7 @@ const webFrame = electron.webFrame; const EnhancedNotification = require('../js/notification'); const UNREAD_COUNT_INTERVAL = 1000; +const CLEAR_CACHE_INTERVAL = 60 * 60 * 1000; // 1 hour Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no-native-reassign @@ -185,3 +186,10 @@ function setSpellChecker() { } setSpellChecker(); ipc.on('set-spellcheker', setSpellChecker); + +// mattermost-webapp is SPA. So cache is not cleared due to no navigation. +// We needed to manually clear cache to free memory in long-term-use. +// http://seenaburns.com/debugging-electron-memory-usage/ +setInterval(() => { + webFrame.clearCache(); +}, CLEAR_CACHE_INTERVAL); From 4ff72cdcff15644b181e07d66d032c0258da4d1c Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Wed, 28 Mar 2018 21:57:40 +0900 Subject: [PATCH 2/2] Tweak interval --- src/browser/webview/mattermost.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser/webview/mattermost.js b/src/browser/webview/mattermost.js index 7157407e..d2f44931 100644 --- a/src/browser/webview/mattermost.js +++ b/src/browser/webview/mattermost.js @@ -7,7 +7,8 @@ const webFrame = electron.webFrame; const EnhancedNotification = require('../js/notification'); const UNREAD_COUNT_INTERVAL = 1000; -const CLEAR_CACHE_INTERVAL = 60 * 60 * 1000; // 1 hour +//eslint-disable-next-line no-magic-numbers +const CLEAR_CACHE_INTERVAL = 6 * 60 * 60 * 1000; // 6 hours Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no-native-reassign