60 peak_ = size_ = rss_ = free_ = 0;
64 void Foam::memInfo::populate()
77 std::ifstream is(
"/proc/meminfo");
82 nkeys && is.good() && std::getline(is, line);
86 const auto delim = line.find(
':');
87 if (delim == std::string::npos)
92 const std::string
key(line.substr(0, delim));
100 free_ = std::stol(line.substr(delim+1));
119 std::ifstream is(
"/proc/" + std::to_string(
Foam::pid()) +
"/status");
124 nkeys && is.good() && std::getline(is, line);
128 const auto delim = line.find(
':');
129 if (delim == std::string::npos)
134 const std::string
key(line.substr(0, delim));
142 peak_ = std::stol(line.substr(delim+1));
145 else if (
key ==
"VmSize")
147 size_ = std::stol(line.substr(delim+1));
150 else if (
key ==
"VmRSS")
152 rss_ = std::stol(line.substr(delim+1));
virtual bool check(const char *operation) const
Check IOstream status for given operation.
int64_t rss() const noexcept
Resident set size at last update - (VmRSS in /proc/PID/status)
void clear() noexcept
Reset to zero.
const memInfo & update()
Update according to /proc/PID/status and /proc/memory contents.
Begin list [isseparator].
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
int64_t free() const noexcept
System memory free (MemFree in /proc/meminfo)
void writeEntry(const word &keyword, Ostream &os) const
Write mem-info as dictionary.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
memInfo()
Construct and populate with values.
A class for handling words, derived from Foam::string.
int64_t peak() const noexcept
Peak memory at last update - (VmPeak in /proc/PID/status)
virtual Ostream & endBlock()
Write end block group.
bool good() const noexcept
True if the memory information appears valid.
pid_t pid()
Return the PID of this process.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
Memory usage information for the current process, and the system memory that is free.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
void writeEntries(Ostream &os) const
Write mem-info as dictionary entries.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
int64_t size() const noexcept
Memory size at last update - (VmSize in /proc/PID/status)