is it possible, in C++, to get the current RAM and CPU usage? Is there a platform-indepentent function call?
On Linux, this will use /proc/self/status . More work is required to turn this into a number. I find this useful as it is though, just to print the memory usage directly to the screen as a string.
static string memory_usage() {
ostringstream mem;
PP("hi");
ifstream proc("/proc/self/status");
string s;
while(getline(proc, s), !proc.fail()) {
if(s.substr(0, 6) == "VmSize") {
mem << s;
return mem.str();
}
}
return mem.str();
}