Class JvmMonitor

java.lang.Object
cz.drg.pregrouper.util.JvmMonitor
All Implemented Interfaces:
AutoCloseable

public final class JvmMonitor extends Object implements AutoCloseable
Utility class for monitoring JVM memory usage and garbage collection events.
  • Constructor Details

    • JvmMonitor

      public JvmMonitor()
    • JvmMonitor

      public JvmMonitor(double maxMemoryUsage, int requiredStrikes)
    • JvmMonitor

      public JvmMonitor(double maxMemoryUsage, double criticalMemoryUsage, int requiredStrikes)
      Parameters:
      maxMemoryUsage - fraction of the watched pool's max that arms the monitor, in (0, 1]
      criticalMemoryUsage - fraction that aborts immediately; must be >= maxMemoryUsage
      requiredStrikes - net post-collection samples above the threshold before shutdown, >= 1
  • Method Details

    • registerForMemUsageChanges

      public void registerForMemUsageChanges()
      Starts monitoring. Call once per instance.
    • close

      public void close()
      Removes listeners and stops the watchdog. Safe to call more than once.
      Specified by:
      close in interface AutoCloseable