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 Type
    Method
    Description
    default void
    Invoked after every GC event, regardless of alert state.
    void
    Invoked when the ratio of time spent in GC over the rolling pressure window exceeds the configured GC pressure threshold.
    void
    Invoked when a GC event causes the rolling pressure ratio to drop back below the threshold, following a prior onGcPressureHigh() notification.
    void
    Invoked when old generation heap usage exceeds the configured memory threshold.
    void
    Invoked after a GC cycle when old generation usage has dropped back below the memory threshold, following a prior onMemoryLow() 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 prior onMemoryLow() 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 prior onGcPressureHigh() 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.