meminfo
This commit is contained in:
parent
b3492b5084
commit
4b72775a5c
@ -2,14 +2,14 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
static size_t getMemKey(std::string key) {
|
static size_t getMemKey(std::string key) {
|
||||||
// # ifdef __linux__
|
# ifdef __linux__
|
||||||
std::string token;
|
std::string token;
|
||||||
std::ifstream f("/proc/meminfo");
|
std::ifstream f("/proc/meminfo");
|
||||||
while (f >> token) {
|
while (f >> token) {
|
||||||
if (token == key) {
|
if (token == key) {
|
||||||
size_t mem_val;
|
size_t mem_val;
|
||||||
if (f >> mem_val) {
|
if (f >> mem_val) {
|
||||||
return mem_val;
|
return mem_val * 1024; // values are in kB
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -17,9 +17,9 @@ static size_t getMemKey(std::string key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
// # else
|
# else
|
||||||
// return 0;
|
return 0;
|
||||||
// # endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getMemAvailable() {
|
size_t getMemAvailable() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user