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

Cross-platform helpers for estimating available RAM and low-memory pressure. More...

#include <cwist/sys/sys_info.h>
#include <cwist/core/macros.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Include dependency graph for sys_info.c:

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   200809L
 

Functions

uint64_t cwist_get_available_ram (void)
 Fallback RAM estimate for unsupported platforms.
 
bool cwist_is_ram_critical (uint64_t threshold_bytes)
 Check whether the current available RAM is below a caller-supplied threshold.
 

Detailed Description

Cross-platform helpers for estimating available RAM and low-memory pressure.

Definition in file sys_info.c.

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Definition at line 1 of file sys_info.c.

Function Documentation

◆ cwist_get_available_ram()

uint64_t cwist_get_available_ram ( void  )

Fallback RAM estimate for unsupported platforms.

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 whether the current available RAM is below a caller-supplied threshold.

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().