remove getSystemMemoryInfo as free memory reported is incorrect
This commit is contained in:
parent
7fabf2c5c9
commit
ae8326a773
|
@ -7,22 +7,16 @@ const SPIKE_DETECTION_INTERVAL_IN_MICROSECONDS = 1 * 1000; // 1 seconds
|
||||||
|
|
||||||
const HIGH_MEMORY_USAGE_THRESHOLD_IN_KILOBYTES = 1 * 1024 * 1024; // 1 GB
|
const HIGH_MEMORY_USAGE_THRESHOLD_IN_KILOBYTES = 1 * 1024 * 1024; // 1 GB
|
||||||
|
|
||||||
const LOW_MEMORY_FREE_THRESHOLD_IN_KILOBYTES = 1 * 1024 * 1024; // 1 GB
|
|
||||||
|
|
||||||
async function logMainProcessStats() {
|
async function logMainProcessStats() {
|
||||||
const processMemoryInfo = await process.getProcessMemoryInfo();
|
const processMemoryInfo = await process.getProcessMemoryInfo();
|
||||||
const normalizedProcessMemoryInfo = await getNormalizedProcessMemoryInfo(
|
const normalizedProcessMemoryInfo = await getNormalizedProcessMemoryInfo(
|
||||||
processMemoryInfo
|
processMemoryInfo
|
||||||
);
|
);
|
||||||
const systemMemoryInfo = process.getSystemMemoryInfo();
|
|
||||||
const normalizedSystemMemoryInfo =
|
|
||||||
getNormalizedSystemMemoryInfo(systemMemoryInfo);
|
|
||||||
const cpuUsage = process.getCPUUsage();
|
const cpuUsage = process.getCPUUsage();
|
||||||
const heapStatistics = getNormalizedHeapStatistics();
|
const heapStatistics = getNormalizedHeapStatistics();
|
||||||
|
|
||||||
ElectronLog.log('main process stats', {
|
ElectronLog.log('main process stats', {
|
||||||
processMemoryInfo: normalizedProcessMemoryInfo,
|
processMemoryInfo: normalizedProcessMemoryInfo,
|
||||||
systemMemoryInfo: normalizedSystemMemoryInfo,
|
|
||||||
heapStatistics,
|
heapStatistics,
|
||||||
cpuUsage,
|
cpuUsage,
|
||||||
});
|
});
|
||||||
|
@ -30,22 +24,16 @@ async function logMainProcessStats() {
|
||||||
|
|
||||||
async function logSpikeMemoryUsage() {
|
async function logSpikeMemoryUsage() {
|
||||||
const processMemoryInfo = await process.getProcessMemoryInfo();
|
const processMemoryInfo = await process.getProcessMemoryInfo();
|
||||||
const systemMemoryInfo = process.getSystemMemoryInfo();
|
|
||||||
if (
|
if (
|
||||||
processMemoryInfo.residentSet >
|
processMemoryInfo.residentSet > HIGH_MEMORY_USAGE_THRESHOLD_IN_KILOBYTES
|
||||||
HIGH_MEMORY_USAGE_THRESHOLD_IN_KILOBYTES ||
|
|
||||||
systemMemoryInfo.free < LOW_MEMORY_FREE_THRESHOLD_IN_KILOBYTES
|
|
||||||
) {
|
) {
|
||||||
const normalizedProcessMemoryInfo =
|
const normalizedProcessMemoryInfo =
|
||||||
await getNormalizedProcessMemoryInfo(processMemoryInfo);
|
await getNormalizedProcessMemoryInfo(processMemoryInfo);
|
||||||
const normalizedSystemMemoryInfo =
|
|
||||||
getNormalizedSystemMemoryInfo(systemMemoryInfo);
|
|
||||||
const cpuUsage = process.getCPUUsage();
|
const cpuUsage = process.getCPUUsage();
|
||||||
const heapStatistics = getNormalizedHeapStatistics();
|
const heapStatistics = getNormalizedHeapStatistics();
|
||||||
|
|
||||||
ElectronLog.log('main process stats', {
|
ElectronLog.log('main process stats', {
|
||||||
processMemoryInfo: normalizedProcessMemoryInfo,
|
processMemoryInfo: normalizedProcessMemoryInfo,
|
||||||
systemMemoryInfo: normalizedSystemMemoryInfo,
|
|
||||||
heapStatistics,
|
heapStatistics,
|
||||||
cpuUsage,
|
cpuUsage,
|
||||||
});
|
});
|
||||||
|
@ -84,19 +72,6 @@ const getNormalizedProcessMemoryInfo = async (
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNormalizedSystemMemoryInfo = (
|
|
||||||
systemMemoryInfo: Electron.SystemMemoryInfo
|
|
||||||
) => {
|
|
||||||
return {
|
|
||||||
total: convertBytesToHumanReadable(systemMemoryInfo.total * 1024),
|
|
||||||
free: convertBytesToHumanReadable(systemMemoryInfo.free * 1024),
|
|
||||||
swapTotal: convertBytesToHumanReadable(
|
|
||||||
systemMemoryInfo.swapTotal * 1024
|
|
||||||
),
|
|
||||||
swapFree: convertBytesToHumanReadable(systemMemoryInfo.swapFree * 1024),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const getNormalizedBlinkMemoryInfo = () => {
|
const getNormalizedBlinkMemoryInfo = () => {
|
||||||
const blinkMemoryInfo = process.getBlinkMemoryInfo();
|
const blinkMemoryInfo = process.getBlinkMemoryInfo();
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue