cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
sys_info.h File Reference

System Resource Monitoring Utilities. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for sys_info.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint64_t cwist_get_available_ram (void)
 Get the available (free + reclaimable) system RAM in bytes.
 
bool cwist_is_ram_critical (uint64_t threshold_bytes)
 Check if system RAM is critically low.
 

Detailed Description

System Resource Monitoring Utilities.

Definition in file sys_info.h.

Function Documentation

◆ cwist_get_available_ram()

uint64_t cwist_get_available_ram ( void  )

Get the available (free + reclaimable) system RAM in bytes.

Uses /proc/meminfo on Linux. Uses sysctl on BSD/macOS.

Returns
Available RAM in bytes, or 0 if detection fails.

Get the available (free + reclaimable) system RAM in bytes.

Returns
Conservative mock availability used when no platform-specific API exists.

Definition at line 90 of file sys_info.c.

References CWIST_GIB.

Referenced by cwist_is_ram_critical(), and cwist_nuke_init().

◆ cwist_is_ram_critical()

bool cwist_is_ram_critical ( uint64_t  threshold_bytes)

Check if system RAM is critically low.

Parameters
threshold_bytesThe minimum bytes that should be available.
Returns
true if available RAM < threshold_bytes.

Check if system RAM is critically low.

Parameters
threshold_bytesThreshold in bytes that marks memory as critical.
Returns
true when the estimated available RAM is below the threshold.

Definition at line 100 of file sys_info.c.

References cap, and cwist_get_available_ram().