module SystemD::MemoryPressure

Overview

Module to monitor memory pressure using systemd's memory pressure notification mechanism.

Defined in:

memory_pressure.cr

Constant Summary

Log = ::Log.for("systemd.memory_pressure")

Class Method Summary

Class Method Detail

def self.monitor(&block : -> ) #

The block is called when memory pressure is detected


[View source]
def self.parse(data : String) : Pressure | Nil #

[View source]
def self.pressure(path : String) : Pressure | Nil #

[View source]
def self.pressure : Pressure | Nil #

Current memory pressure, see .pressure_path for which file is read


[View source]
def self.pressure_path : String | Nil #

The watched file if it is a regular PSI file, otherwise the process' cgroup v2 memory.pressure, falling back to the system wide one


[View source]
def self.watch(release_below : Float64 = 1.0, check_interval : Time::Span = 1.second, &block : Bool -> ) #

The block is called with true when memory pressure is detected and with false when it is relieved. Notifications only signal the onset, so while under pressure the PSI file is polled every check_interval and relief is signalled once its "some avg10" drops below release_below (percent), or at the first check if no PSI file can be read.


[View source]