diff --git a/src/Common/gui/MainWindow.cpp b/src/Common/gui/MainWindow.cpp index 34c026eff..b91a7605c 100755 --- a/src/Common/gui/MainWindow.cpp +++ b/src/Common/gui/MainWindow.cpp @@ -153,7 +153,7 @@ void MainWindow::setupMainTabCornerWidgets() performanceMonitorLabel->setObjectName(QStringLiteral("labelPerformanceMonitor")); #ifndef Q_OS_WIN - performanceMonitorLabel->setVisible(false); // showing RAM monitor in windows only + performanceMonitorLabel->setVisible(false); // showing RAM monitor in windows only #endif transmitTransferRateLabel = new QLabel(this); @@ -2094,7 +2094,7 @@ void MainWindow::timerEvent(QTimerEvent *) ninjamWindow->updatePeaks(); } - // update cpu and memmory usage + // update cpu and RAM usage qint64 now = QDateTime::currentMSecsSinceEpoch(); if (now - lastPerformanceMonitorUpdate >= PERFORMANCE_MONITOR_REFRESH_TIME) { @@ -2103,7 +2103,7 @@ void MainWindow::timerEvent(QTimerEvent *) auto memmoryUsed = performanceMonitor->getMemmoryUsed(); auto batteryUsed = performanceMonitor->getBatteryUsed(); - bool showMemmory = memmoryUsed > 60; //memory meter only active if memory usage is <60% + bool showMemmory = memmoryUsed > 60; //memory meter only active (as an alert) if RAM usage is > 60% bool showBattery = batteryUsed < 255; //Battery meter active only if battery is available QString string; diff --git a/src/Common/performance/LinuxPerformanceMonitor.cpp b/src/Common/performance/LinuxPerformanceMonitor.cpp index 9086a38f2..ae7d480a7 100644 --- a/src/Common/performance/LinuxPerformanceMonitor.cpp +++ b/src/Common/performance/LinuxPerformanceMonitor.cpp @@ -1,5 +1,6 @@ #include "PerformanceMonitor.h" +#include "sys/sysinfo.h" PerformanceMonitor::PerformanceMonitor(){ @@ -10,8 +11,10 @@ PerformanceMonitor::~PerformanceMonitor(){ } int PerformanceMonitor::getMemmoryUsed(){ - - return 0; + struct sysinfo memInfo; + sysinfo (&memInfo); + long long virtualMemUsed = memInfo.totalram - memInfo.freeram ; + return 100 * virtualMemUsed / memInfo.totalram; } int PerformanceMonitor::getBatteryUsed() diff --git a/src/Common/performance/WindowsPerformanceMonitor.cpp b/src/Common/performance/WindowsPerformanceMonitor.cpp index b170d0375..720a2fe34 100644 --- a/src/Common/performance/WindowsPerformanceMonitor.cpp +++ b/src/Common/performance/WindowsPerformanceMonitor.cpp @@ -17,7 +17,7 @@ PerformanceMonitor::~PerformanceMonitor() int PerformanceMonitor::getMemmoryUsed() { - //http://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process + //https://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); bool result = GlobalMemoryStatusEx(&memInfo);