Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
SystemResourceMonitor Namespace Reference

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.
 

Detailed Description

A set of utilities for monitoring and managing system resources.

This group provides functions and variables for:

  • Tracking system memory usage
  • Setting and checking memory limits
  • Measuring elapsed time

Function Documentation

◆ getAbsoluteTimeSeconds()

double SystemResourceMonitor::getAbsoluteTimeSeconds ( )

Get the absolute time in seconds since the epoch.

Returns
Double representing the current time in seconds.

◆ getAvailableMemoryKB()

long SystemResourceMonitor::getAvailableMemoryKB ( )

Get the available system memory in kilobytes(accounts page cache as available).

Returns
Long representing the available memory in KB.

◆ getFreeMemoryKB()

long SystemResourceMonitor::getFreeMemoryKB ( )

Get the free system memory in kilobytes(totally free memory, not even used for cache).

Returns
Long representing the free memory in KB.

◆ getMemoryLimitKB()

rlim_t SystemResourceMonitor::getMemoryLimitKB ( )

Get the current memory limit for the process.

Returns
The memory limit in kilobytes.

◆ getRelativeTimeSeconds()

double SystemResourceMonitor::getRelativeTimeSeconds ( )

Get the relative time in seconds since the program started.

Returns
Double representing the elapsed time in seconds.

◆ getTotalMemoryKB()

long SystemResourceMonitor::getTotalMemoryKB ( )

Get the total system memory in kilobytes.

Returns
Long representing the total memory in KB.

◆ getUsedMemoryKB()

long SystemResourceMonitor::getUsedMemoryKB ( )

Get the used system memory in kilobytes.

Returns
Long representing the used memory in KB.

◆ isMemoryLimitExceeded()

bool SystemResourceMonitor::isMemoryLimitExceeded ( )

Check if the current memory usage exceeds the set limit.

Returns
True if the limit is exceeded, false otherwise.

◆ parseMemInfo()

bool SystemResourceMonitor::parseMemInfo ( const std::string & key,
long & value )

Parse a specific key from /proc/meminfo.

Parameters
keyThe key to search for in /proc/meminfo.
valueReference to store the parsed value.
Returns
True if parsing was successful, false otherwise.

◆ setMemoryLimitKB()

bool SystemResourceMonitor::setMemoryLimitKB ( rlim_t limitInKB)

Set the memory limit for the process.

Parameters
limitInKBThe memory limit to set in kilobytes.
Returns
True if the limit was set successfully, false otherwise.