From 286ca237a2e58271e6b8f81c5c8f2d2a5acea509 Mon Sep 17 00:00:00 2001 From: ColumbusTech Date: Mon, 27 Nov 2017 19:15:50 +0300 Subject: [PATCH] RAM info upgrated --- Info.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Info.hpp b/Info.hpp index ff4953b..67c1fe9 100644 --- a/Info.hpp +++ b/Info.hpp @@ -142,7 +142,7 @@ namespace Columbus #ifdef __linux__ struct sysinfo info; if (sysinfo(&info) == -1) return 0; - return info.totalram; + return info.totalram / (1024 * 1024); #endif #ifdef COLUMBUS_PLATFORM_WINDOWS @@ -160,7 +160,7 @@ namespace Columbus #ifdef __linux__ struct sysinfo info; if (sysinfo(&info) == -1) return 0; - return info.freeram; + return info.freeram / (1024 * 1024); #endif #ifdef COLUMBUS_PLATFORM_WINDOWS @@ -186,6 +186,13 @@ namespace Columbus int GetRAMUsage() { + #ifdef __linux__ + struct sysinfo info; + if (sysinfo(&info) == -1) return 0; + float usage = static_cast(GetRAMFree()) / static_cast(GetRAMSize()); + return static_cast(100 - usage * 100); + #endif + #ifdef COLUMBUS_PLATFORM_WINDOWS MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(memInfo);