55 std::ifstream is(
"/proc/meminfo");
86 peak_ = size_ = rss_ = free_ = 0;
90void Foam::memInfo::populate()
107 std::ifstream is(
"/proc/meminfo");
114 nkeys && is.good() && std::getline(is, line);
118 const auto delim = line.find(
':');
119 if (delim == std::string::npos)
126 #define isKeyEqual(Key) (!line.compare(0, delim, Key))
132 const char * value = (
line.data() + (delim+1));
133 char *endptr =
nullptr;
136 #define parseValue (std::strtol(value, &endptr, 10))
169 std::ifstream is(
"/proc/" + std::to_string(
Foam::pid()) +
"/status");
176 nkeys && is.good() && std::getline(is,
line);
180 const auto delim =
line.find(
':');
181 if (delim == std::string::npos)
188 #define isKeyEqual(Key) (!line.compare(0, delim, Key))
194 const char * value = (
line.data() + (delim+1));
195 char *endptr =
nullptr;
198 #define parseValue (std::strtol(value, &endptr, 10))
239 os.writeEntry(
"size", size_);
240 os.writeEntry(
"peak", peak_);
241 os.writeEntry(
"rss", rss_);
242 os.writeEntry(
"free", free_);
243 os.writeEntry(
"units",
"kB");
249 os.beginBlock(keyword);
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...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Memory usage information for the current process, and the system memory that is free.
void clear() noexcept
Reset to zero.
int64_t peak() const noexcept
Peak memory at last update - (VmPeak in /proc/PID/status).
bool good() const noexcept
True if the memory information appears valid.
memInfo()
Construct and populate with values.
int64_t size() const noexcept
Memory size at last update - (VmSize in /proc/PID/status).
void writeEntries(Ostream &os) const
Write mem-info as dictionary entries.
void writeEntry(const word &keyword, Ostream &os) const
Write mem-info as dictionary.
int64_t rss() const noexcept
Resident set size at last update - (VmRSS in /proc/PID/status).
int64_t free() const noexcept
System memory free (MemFree in /proc/meminfo).
static bool supported()
True if memory information appears to be supported.
const memInfo & update()
Update according to /proc/PID/status and /proc/memory contents.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
static int is_supported(-1)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
pid_t pid()
Return the PID of this process.