Skip to main content

Module memory_guard

Module memory_guard 

Source
Expand description

Process-level RAM guardian with adaptive eviction.

Monitors RSS via platform-specific APIs and triggers tiered cache eviction when memory usage exceeds configurable thresholds (default: 5% of system RAM).

Structs§

MemorySnapshot
Snapshot of current memory state for diagnostics.

Enums§

PressureLevel

Functions§

force_purge
Force immediate purge of all caches and jemalloc arenas.
get_rss_bytes
Current process RSS in bytes, or None if unavailable.
get_system_ram_bytes
Total physical RAM in bytes, or None if unavailable.
jemalloc_purge
Force-purge all jemalloc arenas to return memory to the OS.
peak_rss_bytes
Recorded peak RSS since process start.
rss_limit_bytes
Returns the RSS limit in bytes based on max_ram_percent config.
start_guard
Start the background memory guardian task (idempotent).