26 #include <sys/resource.h> 40 long int memoryUsage = -1;
43 HANDLE hProc = GetCurrentProcess();
44 PROCESS_MEMORY_COUNTERS info;
45 BOOL okay = GetProcessMemoryInfo(hProc, &info,
sizeof(info));
48 memoryUsage = info.WorkingSetSize;
52 if(getrusage(RUSAGE_SELF, &u) == 0)
54 memoryUsage = u.ru_maxrss;
57 std::fstream file(
"/proc/self/status", std::fstream::in);
61 while(std::getline(file, bytes))
63 if(bytes.find(
"VmRSS") != bytes.npos)
65 std::list<std::string> strs =
uSplit(bytes,
' ');
68 memoryUsage = atol(
uValueAt(strs,1).c_str()) * 1024;
V & uValueAt(std::list< V > &list, const unsigned int &pos)
std::list< std::string > uSplit(const std::string &str, char separator= ' ')
Wrappers of STL for convenient functions.
static long int getMemoryUsage()