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) { 
  string line, key, value;
  std::ifstream stream(kProcDirectory + to_string(pid) + kStatusFilename);
  if (stream.is_open()) {
    while (std::getline(stream, line)) {
      std::istringstream linestream(line);
      while (linestream >> key >> value) {
        if (key == "VmSize:") {
          return value;
        }
      }
    }
  }
  return value;
}
string LinuxParser :: Ram ( int pid ) { string line , key , value ; std :: ifstream stream ( kProcDirectory + to_string ( pid ) + kStatusFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: istringstream linestream ( line ) ; while ( linestream >> key >> value ) { if ( key == " " ) { return value ; } } } } return value ; }
Read and return the memory used by a process
Read and return the memory used by a process