A set of utilities for monitoring and managing system resources. More...
Functions | |
double | getRelativeTimeSeconds () |
Get the relative time in seconds since the program started. | |
double | getAbsoluteTimeSeconds () |
Get the absolute time in seconds since the epoch. | |
bool | parseMemInfo (const std::string &key, long &value) |
Parse a specific key from /proc/meminfo. | |
long | getTotalMemoryKB () |
Get the total system memory in kilobytes. | |
long | getUsedMemoryKB () |
Get the used system memory in kilobytes. | |
long | getFreeMemoryKB () |
Get the free system memory in kilobytes(totally free memory, not even used for cache). | |
long | getAvailableMemoryKB () |
Get the available system memory in kilobytes(accounts page cache as available). | |
bool | setMemoryLimitKB (rlim_t limitInKB) |
Set the memory limit for the process. | |
rlim_t | getMemoryLimitKB () |
Get the current memory limit for the process. | |
bool | isMemoryLimitExceeded () |
Check if the current memory usage exceeds the set limit. | |
void | printProcessResourceUsage () |
Pretty print for the resource usage data gotten from getrusage() | |
Variables | |
std::atomic< rlim_t > | memoryLimitKB |
The current memory limit for the process in kilobytes. | |
const std::chrono::steady_clock::time_point | startTime |
The start time of the program. | |
A set of utilities for monitoring and managing system resources.
This group provides functions and variables for:
double SystemResourceMonitor::getAbsoluteTimeSeconds | ( | ) |
Get the absolute time in seconds since the epoch.
long SystemResourceMonitor::getAvailableMemoryKB | ( | ) |
Get the available system memory in kilobytes(accounts page cache as available).
long SystemResourceMonitor::getFreeMemoryKB | ( | ) |
Get the free system memory in kilobytes(totally free memory, not even used for cache).
rlim_t SystemResourceMonitor::getMemoryLimitKB | ( | ) |
Get the current memory limit for the process.
double SystemResourceMonitor::getRelativeTimeSeconds | ( | ) |
Get the relative time in seconds since the program started.
long SystemResourceMonitor::getTotalMemoryKB | ( | ) |
Get the total system memory in kilobytes.
long SystemResourceMonitor::getUsedMemoryKB | ( | ) |
Get the used system memory in kilobytes.
bool SystemResourceMonitor::isMemoryLimitExceeded | ( | ) |
Check if the current memory usage exceeds the set limit.
bool SystemResourceMonitor::parseMemInfo | ( | const std::string & | key, |
long & | value ) |
Parse a specific key from /proc/meminfo.
key | The key to search for in /proc/meminfo. |
value | Reference to store the parsed value. |
bool SystemResourceMonitor::setMemoryLimitKB | ( | rlim_t | limitInKB | ) |
Set the memory limit for the process.
limitInKB | The memory limit to set in kilobytes. |