Class JvmMemoryPressure
java.lang.Object
com.kingsrook.qqq.backend.core.health.JvmMemoryPressure
Tracks whether this JVM is under sustained memory pressure: the heap still
full after garbage collection, or the JVM spending a large share of wall
time in GC pauses. A JVM in that state answers every request slowly for
minutes before it throws OutOfMemoryError, so probes use it to take the pod
out of the load balancer (readiness) and, if it lasts, restart it
(liveness).
Readings are taken when a probe or the health runner asks (kubelet probes
every few seconds); nothing runs in the background. Each reading compares
against the oldest sample still inside the window:
- heap after GC is the lowest after-GC occupancy seen in the window, so
one full collection that frees the heap clears the condition;
- GC time is the pause time added across the window divided by its length.
Pressure starts when either crosses its threshold and ends only when the
latest heap after GC is below the recovery percent and GC time is below
its threshold, so a JVM near the line does not flap.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPlatform MXBeans: summed after-GC usage of heap pools, and pause time of collectors that stop the world.static final recordOne evaluation.static final recordThresholds, all from system properties or environment variables.static interfaceWhere readings come from: the platform MXBeans, or a test double. -
Constructor Summary
ConstructorsConstructorDescriptionJvmMemoryPressure(JvmMemoryPressure.Settings settings, JvmMemoryPressure.Source source, Clock clock) Constructor (tests inject a source and clock). -
Method Summary
Modifier and TypeMethodDescriptionstatic JvmMemoryPressureget()The JVM-wide monitor, configured from the environment on first use.Getter for settingssample()Take a sample and evaluate the window.static voidset(JvmMemoryPressure monitor) Replace the JVM-wide monitor (tests); null re-reads the environment.
-
Constructor Details
-
JvmMemoryPressure
public JvmMemoryPressure(JvmMemoryPressure.Settings settings, JvmMemoryPressure.Source source, Clock clock) Constructor (tests inject a source and clock).
-
-
Method Details
-
get
The JVM-wide monitor, configured from the environment on first use. -
set
Replace the JVM-wide monitor (tests); null re-reads the environment. -
getSettings
Getter for settings -
sample
Take a sample and evaluate the window.
-