MemoryMonitor class
#include <gtopt/memory_monitor.hpp>
Public static functions
- static auto get_system_memory_snapshot(double fallback_total_mb = 4096.0) -> MemorySnapshot noexcept
- Read current memory state from /proc (static, no background thread).
Constructors, destructors, conversion operators
- MemoryMonitor() defaulted
- MemoryMonitor(const MemoryMonitor&) deleted
- MemoryMonitor(MemoryMonitor&&) deleted
- ~MemoryMonitor()
Public functions
- auto get_available_mb() const -> double noexcept
- System available memory in MB.
- auto get_interval() const -> auto noexcept
- auto get_memory_percent() const -> double noexcept
- System memory usage as percentage (0–100).
- auto get_process_rss_mb() const -> double noexcept
- Process RSS in MB.
- auto get_process_swap_mb() const -> double noexcept
- Process bytes paged out to swap (VmSwap from /proc/self/status) in MB.
- auto get_swap_io_rate() const -> double noexcept
- auto get_swap_used_mb() const -> double noexcept
- System-wide swap usage in MB (SwapTotal - SwapFree).
- auto get_total_mb() const -> double noexcept
- Total system memory in MB.
- void notify_stop() noexcept
- auto operator=(const MemoryMonitor&) -> MemoryMonitor& deleted
- auto operator=(MemoryMonitor&&) -> MemoryMonitor& deleted
- void request_stop() noexcept
- Signal the monitor thread to wind down without joining.
- void set_interval(std::chrono::milliseconds interval) noexcept
- void start()
- void stop() noexcept
Function documentation
double gtopt:: MemoryMonitor:: get_swap_io_rate() const noexcept
Observed swap I/O rate (pages in + pages out per second), averaged over the previous monitor interval. Near zero under normal operation; rises sharply when the kernel is thrashing pages to or from swap.
void gtopt:: MemoryMonitor:: request_stop() noexcept
Signal the monitor thread to wind down without joining.
Phase-1 helper used by BasicWorkPool::shutdown(). See the matching docstring on CPUMonitor::request_stop / notify_stop for the rationale: signalling these monitors before joining the worker pool lets their wait_for(monitor_interval_, ...) predicate observe the stop request immediately, so the later .stop() call's join() is near-instant rather than blocking up to 500 ms.