mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reset parameters in memInfo::update()
- avoids old values if the read from /proc/.../status somehow failed
This commit is contained in:
@ -47,6 +47,8 @@ Foam::memInfo::~memInfo()
|
||||
|
||||
const Foam::memInfo& Foam::memInfo::update()
|
||||
{
|
||||
// reset to invalid values first
|
||||
peak_ = size_ = rss_ = -1;
|
||||
IFstream is("/proc/" + name(pid()) + "/status");
|
||||
|
||||
while (is.good())
|
||||
|
||||
@ -27,6 +27,9 @@ Class
|
||||
Description
|
||||
Memory usage information for the process running this object.
|
||||
|
||||
Note
|
||||
Uses the information from /proc/\<pid\>/status
|
||||
|
||||
SourceFiles
|
||||
memInfo.C
|
||||
|
||||
@ -52,13 +55,13 @@ class memInfo
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Peak memory used by the process (VmPeak in /proc/<pid>/status)
|
||||
//- Peak memory used by the process (VmPeak in /proc/\<pid\>/status)
|
||||
int peak_;
|
||||
|
||||
//- Memory used by the process (VmSize in /proc/<pid>/status)
|
||||
//- Memory used by the process (VmSize in /proc/\<pid\>/status)
|
||||
int size_;
|
||||
|
||||
//- Resident set size of the process (VmRSS in /proc/<pid>/status)
|
||||
//- Resident set size of the process (VmRSS in /proc/\<pid\>/status)
|
||||
int rss_;
|
||||
|
||||
|
||||
@ -76,24 +79,27 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Parse /proc/<pid>/status
|
||||
//- Parse /proc/\<pid\>/status
|
||||
const memInfo& update();
|
||||
|
||||
// Access
|
||||
|
||||
//- Access the stored peak memory
|
||||
//- Access the stored peak memory (VmPeak in /proc/\<pid\>/status)
|
||||
// The value is stored from the previous update()
|
||||
int peak() const
|
||||
{
|
||||
return peak_;
|
||||
}
|
||||
|
||||
//- Access the stored memory size
|
||||
//- Access the stored memory size (VmSize in /proc/\<pid\>/status)
|
||||
// The value is stored from the previous update()
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
//- Access the stored rss value
|
||||
//- Access the stored rss value (VmRSS in /proc/\<pid\>/status)
|
||||
// The value is stored from the previous update()
|
||||
int rss() const
|
||||
{
|
||||
return rss_;
|
||||
@ -102,7 +108,10 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Read peak/size/rss from stream
|
||||
friend Istream& operator>>(Istream&, memInfo&);
|
||||
|
||||
//- Write peak/size/rss to stream
|
||||
friend Ostream& operator<<(Ostream&, const memInfo&);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user