59 peak_ = size_ = rss_ = 0;
80 std::ifstream is(
"/proc/" + std::to_string(
Foam::pid()) +
"/status");
85 nkeys && is.good() && std::getline(is,
line);
89 const auto delim =
line.find(
':');
90 if (delim == std::string::npos)
95 const std::string
key(line.substr(0, delim));
103 peak_ = std::stoi(line.substr(delim+1));
106 else if (
key ==
"VmSize")
108 size_ = std::stoi(line.substr(delim+1));
111 else if (
key ==
"VmRSS")
113 rss_ = std::stoi(line.substr(delim+1));
128 std::ifstream is(
"/proc/meminfo");
133 nkeys && is.good() && std::getline(is, line);
137 const auto delim = line.find(
':');
138 if (delim == std::string::npos)
143 const std::string
key = line.substr(0, delim);
149 if (
key ==
"MemFree")
151 free_ = std::stoi(line.substr(delim+1));
175 is >> m.peak_ >> m.size_ >> m.rss_ >> m.free_;
176 is.readEnd(
"memInfo");
virtual bool check(const char *operation) const
Check IOstream status for given operation.
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
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.
void clear()
Reset to zero.
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.
Istream & operator>>(Istream &, directionInfo &)
bool valid() const
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)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
void write(Ostream &os) const
Write content as dictionary entries.