Skip to content

Commit

Permalink
Merge pull request #746 from yuya-oc/clear-memory-cache
Browse files Browse the repository at this point in the history
Clear webFrame cache at a certain interval
  • Loading branch information
yuya-oc authored Apr 2, 2018
2 parents afccab3 + 4ff72cd commit 7379d02
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/browser/webview/mattermost.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const webFrame = electron.webFrame;
const EnhancedNotification = require('../js/notification');

const UNREAD_COUNT_INTERVAL = 1000;
//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

Expand Down Expand Up @@ -185,3 +187,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);

0 comments on commit 7379d02

Please sign in to comment.