CARMA C++
|
Class to get virtual memory size of a process. More...
#include <carma/util/VmSize.h>
Public Member Functions | |
double | getSizeHuman () |
Returns last measured size, in human readable units. More... | |
int | getSizeKB () |
Returns the last measured size, in KB. More... | |
std::string | getStringHuman (int precision=2) |
Returns a string with size and units in human readable units for last measured vm size. More... | |
std::string | getUnitsHuman () |
Returns the human readable units for last measured size. More... | |
void | refresh () |
Get the current VM size for the process specified in the constructor. More... | |
VmSize () | |
Default constructor; vmsize for current process. More... | |
VmSize (pid_t pid) | |
Constructor for a specified process This gets the VM size at the time of construction. More... | |
Class to get virtual memory size of a process.
The information is gotten from the /proc filesystem, in the same way that ps works. Specifically, we use /proc/pid/status. This class could easily be expanded to get other memory quantities that are present in this same file.
carma::util::VmSize::VmSize | ( | ) |
Default constructor; vmsize for current process.
This gets the VM size at the time of construction.
carma::util::VmSize::VmSize | ( | pid_t | pid | ) |
Constructor for a specified process This gets the VM size at the time of construction.
pid | process ID for the VM size. |
double carma::util::VmSize::getSizeHuman | ( | ) |
Returns last measured size, in human readable units.
int carma::util::VmSize::getSizeKB | ( | ) |
Returns the last measured size, in KB.
std::string carma::util::VmSize::getStringHuman | ( | int | precision = 2 | ) |
Returns a string with size and units in human readable units for last measured vm size.
precision | number of digits to the right of the decimal (default = 2) |
std::string carma::util::VmSize::getUnitsHuman | ( | ) |
Returns the human readable units for last measured size.
void carma::util::VmSize::refresh | ( | ) |
Get the current VM size for the process specified in the constructor.