CARMA C++
carma::util::VmSize Class Reference

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...
 

Detailed Description

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.

Definition at line 31 of file VmSize.h.

Constructor & Destructor Documentation

carma::util::VmSize::VmSize ( )

Default constructor; vmsize for current process.

This gets the VM size at the time of construction.

See Also
refresh
carma::util::VmSize::VmSize ( pid_t  pid)

Constructor for a specified process This gets the VM size at the time of construction.

Parameters
pidprocess ID for the VM size.
See Also
refresh

Member Function Documentation

double carma::util::VmSize::getSizeHuman ( )

Returns last measured size, in human readable units.

See Also
getUnitsHuman, getStringHuman
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.

Parameters
precisionnumber of digits to the right of the decimal (default = 2)
See Also
getSizeHuman, getUnitsHuman
std::string carma::util::VmSize::getUnitsHuman ( )

Returns the human readable units for last measured size.

See Also
getSizeHuman, getStringHuman
void carma::util::VmSize::refresh ( )

Get the current VM size for the process specified in the constructor.


The documentation for this class was generated from the following file: