src/linux_parser.cpp
// Read and return the memory used by a process
Read and return the memory used by a process
Read and return the memory used by a process
string LinuxParser::Ram(int pid) { 
  std::ifstream RmFile(kProcDirectory+to_string(pid)+kStatusFilename);
  string line,key,value; 
  while(std::getline(RmFile,line))
  {
  std::istringstream RMStream(line);
  RMStream >> key >> value;
  if(key == "VmSize:")
    return to_string( static_cast<int>(atoi(value.c_str()))/1024);
  }
  return "";
 }
string LinuxParser :: Ram ( int pid ) { std :: ifstream RmFile ( kProcDirectory + to_string ( pid ) + kStatusFilename ) ; string line , key , value ; while ( std :: getline ( RmFile , line ) ) { std :: istringstream RMStream ( line ) ; RMStream >> key >> value ; if ( key == " " ) return to_string ( static_cast < int > ( atoi ( value . c_str ( ) ) ) / 1024 ) ; } return " " ; }
Read and return the memory used by a process
Read and return the memory used by a process