From c20138ea5c1e0e110984c5ce0ee9fa70c23c8312 Mon Sep 17 00:00:00 2001 From: ColumbusTech Date: Mon, 27 Nov 2017 19:51:21 +0300 Subject: [PATCH] RAM info upgrated --- Info.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Info.hpp b/Info.hpp index 67c1fe9..ec132a0 100644 --- a/Info.hpp +++ b/Info.hpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -175,6 +176,25 @@ namespace Columbus unsigned long GetRAMThis() { + #ifdef __linux__ + FILE* fp = fopen("/proc/self/status", "r"); + char line[512]; + + while (fgets(line, 512, fp) != NULL) + { + if (strncmp(line, "VmRSS:", 6) == 0) + { + fclose(fp); + std::string l = line; + l = l.substr(6, l.size() - 4); + return atoi(l.c_str()) / 1024; + } + } + + + fclose(fp); + #endif + #ifdef COLUMBUS_PLATFORM_WINDOWS PROCESS_MEMORY_COUNTERS meminfo; GetProcessMemoryInfo(GetCurrentProcess(), &meminfo, sizeof(meminfo));