From fa27f1976e800c8e224a89ea4317ca29a23a1f3d Mon Sep 17 00:00:00 2001 From: goeiecool9999 <> Date: Sat, 10 Sep 2022 14:33:54 +0200 Subject: [PATCH] Use smaps_rollup for more accurate info. --- src/util/SystemInfo/SystemInfoLinux.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/util/SystemInfo/SystemInfoLinux.cpp b/src/util/SystemInfo/SystemInfoLinux.cpp index 07fe9aea..954b1559 100644 --- a/src/util/SystemInfo/SystemInfoLinux.cpp +++ b/src/util/SystemInfo/SystemInfoLinux.cpp @@ -2,30 +2,21 @@ #include "util/SystemInfo/SystemInfo.h" -#include #include uint64 QueryRamUsage() { - long page_size = sysconf(_SC_PAGESIZE); - if (page_size == -1) - { - return 0; - } - - std::ifstream file("/proc/self/statm"); + std::ifstream file("/proc/self/smaps_rollup"); if (file) { + file.ignore(std::numeric_limits::max(), '\n'); file.ignore(std::numeric_limits::max(), ' '); - uint64 no_pages; - file >> no_pages; + uint64 kilobytes; + file >> kilobytes; - return no_pages * page_size; - } - else - { - return 0; + return kilobytes / 1000; } + return 0; } void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel) @@ -64,4 +55,4 @@ void QueryCoreTimes(uint32 count, ProcessorTime out[]) } } -#endif \ No newline at end of file +#endif