class

KemalWAF::MemoryTracker

Inherits Reference / Object

============================================================================= Memory Usage Tracker

Tracks memory usage per module with atomic counters Provides graceful degradation when limits are exceeded

Constants

Log = ::Log.for("memory_tracker")

Constructors

instance
Source

Instance methods

allocate(mod : MemoryModule, bytes : Int64) : Bool

Allocate memory for a module (returns false if limit exceeded)

Source
at_capacity?(mod : MemoryModule, threshold : Float64 = 90.0) : Bool

Check if module is at or near capacity

Source
free(mod : MemoryModule, bytes : Int64)

Free memory for a module

Source
limit(mod : MemoryModule) : Int64

Get limit for a module

Source
on_degradation(mod : MemoryModule, &block : Int64 -> Nil)

Register degradation callback for a module

Source
reset

Reset all counters (for testing)

Source
stats

Get all module stats

Source
total_usage

Get total WAF memory usage

Source
try_allocate(mod : MemoryModule, bytes : Int64, eviction_callback : Proc(Int64, Int64) | Nil = nil) : Bool

Try to allocate, with automatic eviction if needed

Source
usage(mod : MemoryModule) : Int64

Get current usage for a module

Source
usage_percent(mod : MemoryModule) : Float64

Get usage percentage for a module

Source