Interface MemoryMonitor.Listener
- All Known Implementing Classes:
DynamicMemoryResizer
- Enclosing class:
MemoryMonitor
public static interface MemoryMonitor.Listener
Receives notifications when the monitor detects memory state transitions. Each callback fires
exactly once per transition — repeated signals in the same state are suppressed.
Callbacks are dispatched on the Executor supplied at registration
time. See MemoryMonitor.addListener(Listener, Executor) for details.
- Since:
- 16.2
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidInvoked after every GC event, regardless of alert state.voidInvoked when the ratio of time spent in GC over the rolling pressure window exceeds the configured GC pressure threshold.voidInvoked when a GC event causes the rolling pressure ratio to drop back below the threshold, following a prioronGcPressureHigh()notification.voidInvoked when old generation heap usage exceeds the configured memory threshold.voidInvoked after a GC cycle when old generation usage has dropped back below the memory threshold, following a prioronMemoryLow()notification.
-
Method Details
-
onMemoryLow
void onMemoryLow()Invoked when old generation heap usage exceeds the configured memory threshold. Fires once when the threshold is first crossed; subsequent JMX notifications while already in the low memory state are suppressed. -
onMemoryRecovered
void onMemoryRecovered()Invoked after a GC cycle when old generation usage has dropped back below the memory threshold, following a prioronMemoryLow()notification. -
onGcPressureHigh
void onGcPressureHigh()Invoked when the ratio of time spent in GC over the rolling pressure window exceeds the configured GC pressure threshold. Fires once on the transition; further GC events while pressure remains high are suppressed. -
onGcPressureRelieved
void onGcPressureRelieved()Invoked when a GC event causes the rolling pressure ratio to drop back below the threshold, following a prioronGcPressureHigh()notification. -
onGcCompleted
default void onGcCompleted()Invoked after every GC event, regardless of alert state. Useful for listeners that need to recheck their own state after GC has reclaimed memory — for example, to verify whether a previous corrective action (like shrinking a container) was sufficient.
-