Package cz.drg.pregrouper.util
Class JvmMonitor
java.lang.Object
cz.drg.pregrouper.util.JvmMonitor
- All Implemented Interfaces:
AutoCloseable
Utility class for monitoring JVM memory usage and garbage collection events.
-
Constructor Summary
ConstructorsConstructorDescriptionJvmMonitor(double maxMemoryUsage, double criticalMemoryUsage, int requiredStrikes) JvmMonitor(double maxMemoryUsage, int requiredStrikes) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Removes listeners and stops the watchdog.voidStarts monitoring.
-
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 >= maxMemoryUsagerequiredStrikes- 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:
closein interfaceAutoCloseable
-