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