src/linux_parser.cpp
// TODO: Read and return the memory used by a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the memory used by a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the memory used by a process REMOVE : [[ maybe_unused ]] once you define the function
string LinuxParser::Ram(int pid) 
{ 
  std::string line, key;
  std::string ramValue = "";
  std::ifstream filestream(kProcDirectory + "/" + std::to_string(pid) + kStatusFilename);
  if (filestream.is_open()) {
    while (std::getline(filestream, line)) {
      std::replace(line.begin(), line.end(), ':', ' ');
      std::istringstream linestream(line);
      while (linestream >> key >> ramValue) {
        if (key == "VmData") {
          return ramValue; 
        }
      }
    }
  }
  return ramValue; 
  }
string LinuxParser :: Ram ( int pid ) { std :: string line , key ; std :: string ramValue = " " ; std :: ifstream filestream ( kProcDirectory + " " + std :: to_string ( pid ) + kStatusFilename ) ; if ( filestream . is_open ( ) ) { while ( std :: getline ( filestream , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream linestream ( line ) ; while ( linestream >> key >> ramValue ) { if ( key == " " ) { return ramValue ; } } } } return ramValue ; }
TODO: Read and return the memory used by a process
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the memory used by a process REMOVE : [[ maybe_unused ]] once you define the function
// using KeyWork VmData over VmSize since Former reflect virtual memory, later reflect physical memory