ELECTRON-445 (Change the memory refresh logic to auto-refresh after 4Hrs of user inactivity) (#415)

- Change the memory refresh logic to auto refresh after 4Hrs
This commit is contained in:
Kiran Niranjan 2018-07-02 17:17:01 +05:30 committed by Vishwas Shashidhar
parent 9552e83549
commit e6d16241f8
2 changed files with 3 additions and 8 deletions

View File

@ -8,9 +8,7 @@ const { getConfigField } = require('./config');
const maxMemory = 800;
let maxIdleTime = 15 * 60 * 1000;
let reloadThreshold = 60 * 60 * 1000;
let reloadedTimeStamp;
let maxIdleTime = 4 * 60 * 60 * 1000;
let isInMeeting = false;
// once a minute
@ -39,13 +37,10 @@ function gatherMemory() {
*/
function optimizeMemory(memoryInfo, cpuUsage) {
const memoryConsumed = (memoryInfo && memoryInfo.workingSetSize / 1024) || 0;
const canReload = (!reloadedTimeStamp || (new Date().getTime() - reloadedTimeStamp) > reloadThreshold);
if (memoryConsumed > maxMemory
&& systemIdleTime.getIdleTime() > maxIdleTime
&& canReload
&& !isInMeeting
&& cpuUsage.percentCPUUsage < 1
) {
getConfigField('memoryRefresh')
.then((enabled) => {
@ -54,7 +49,6 @@ function optimizeMemory(memoryInfo, cpuUsage) {
if (mainWindow && !mainWindow.isDestroyed()) {
setIsAutoReload(true);
reloadedTimeStamp = new Date().getTime();
log.send(logLevels.INFO, 'Reloading the app to optimize memory usage as' +
' memory consumption was ' + memoryConsumed +
' CPU usage percentage was ' + cpuUsage.percentCPUUsage +

View File

@ -22,6 +22,7 @@ const getMediaSource = require('../desktopCapturer/getSource');
const { TitleBar, updateContentHeight } = require('../windowsTitlebar');
const titleBar = new TitleBar();
const { buildNumber } = require('../../package.json');
const memoryMonitorInterval = 1000 * 60 * 60;
require('../downloadManager');
@ -80,7 +81,7 @@ setInterval(() => {
memory: memory,
cpuUsage: cpuUsage
});
}, 1000 * 60 * 15);
}, memoryMonitorInterval);
createAPI();