Interface MemoryMonitorMBean

All Superinterfaces:
SelfEmailingMBean

public interface MemoryMonitorMBean extends SelfEmailingMBean
Builds upon Java's built-in java.lang.management.MemoryMXBean to provide additional functionality, including percentage usage and minimum free memory based monitoring of overall heap usage and percentage-based monitoring of the old and perm-gen/metaspace memory pools.

Note that one can attempt to free up memory in response to any of this MBean's notifications except MIN_HEAP_NOT_AVAIL_NOTIF_TYPE, where it is already too late. One should use MIN_HEAP_NOT_AVAIL_INITIAL_NOTIF_TYPE instead for this purpose.

Supported API: true

Extendable: true

  • Field Details

    • HEAP_PERC_USAGE_TE_INITIAL_NOTIF_TYPE

      static final String HEAP_PERC_USAGE_TE_INITIAL_NOTIF_TYPE
      Type of notification produced when HeapPercentUsageThreshold is initially exceeded

      Supported API: true
    • HEAP_PERC_USAGE_TE_STILL_NOTIF_TYPE

      static final String HEAP_PERC_USAGE_TE_STILL_NOTIF_TYPE
      Type of notification produced when HeapPercentUsageThreshold is still exceeded

      Supported API: true
    • HEAP_PERC_USAGE_TE_NO_LONGER_NOTIF_TYPE

      static final String HEAP_PERC_USAGE_TE_NO_LONGER_NOTIF_TYPE
      Type of notification produced when HeapPercentUsageThreshold is no longer exceeded

      Supported API: true
    • MIN_HEAP_NOT_AVAIL_INITIAL_NOTIF_TYPE

      static final String MIN_HEAP_NOT_AVAIL_INITIAL_NOTIF_TYPE
      Type of notification produced when it is found that MinAvailableHeapThreshold bytes of heap are not currently available even after garbage collection. Synchronous (in-process) listeners can attempt to free up memory in response to this notification.

      Supported API: true
    • MIN_HEAP_NOT_AVAIL_NOTIF_TYPE

      static final String MIN_HEAP_NOT_AVAIL_NOTIF_TYPE
      Type of notification produced when it is found that MinAvailableHeapThreshold bytes cannot be allocated on the heap. After this notification is produced the JVM will be forcibly euthanized (killed).

      Supported API: true
    • MIN_HEAP_NOT_AVAIL_NO_LONGER_NOTIF_TYPE

      static final String MIN_HEAP_NOT_AVAIL_NO_LONGER_NOTIF_TYPE
      Type of notification produced when a MIN_HEAP_NOT_AVAIL_INITIAL_NOTIF_TYPE notification has been sent, but the need to send a MIN_HEAP_NOT_AVAIL_NOTIF_TYPE notification and euthanize the JVM has been avoided.

      Supported API: true
    • MEMORY_POOL_USAGE_TE_NOTIF_TYPE

      static final String MEMORY_POOL_USAGE_TE_NOTIF_TYPE
      Type of notification produced when a PercentUsageThreshold is exceeded

      Supported API: true
      See Also:
    • MEMORY_POOL_COLL_USAGE_TE_NOTIF_TYPE

      static final String MEMORY_POOL_COLL_USAGE_TE_NOTIF_TYPE
      Type of notification produced when a PercentCollUsageThreshold is exceeded

      Supported API: true
      See Also:
    • MEMORY_POOL_USAGE_TE_NO_LONGER_NOTIF_TYPE

      static final String MEMORY_POOL_USAGE_TE_NO_LONGER_NOTIF_TYPE
      Type of notification produced when a PercentUsageThreshold is no longer exceeded

      Supported API: true
    • MEMORY_POOL_COLL_USAGE_TE_NO_LONGER_NOTIF_TYPE

      static final String MEMORY_POOL_COLL_USAGE_TE_NO_LONGER_NOTIF_TYPE
      Type of notification produced when a PercentCollUsageThreshold is no longer exceeded

      Supported API: true
  • Method Details

    • getOldGenPercentUsageThreshold

      double getOldGenPercentUsageThreshold()
      Percent usage threshold for old generation memory pool

      Supported API: true
    • setOldGenPercentUsageThreshold

      void setOldGenPercentUsageThreshold(double oldGenPercentUsageThreshold)
      Percent usage threshold for old generation memory pool

      Supported API: true
    • getOldGenPercentUsage

      double getOldGenPercentUsage()
      Current old generation pool percent usage

      Supported API: true
    • getOldGenPercentCollUsageThreshold

      double getOldGenPercentCollUsageThreshold()
      Percent collection usage threshold for old generation memory pool

      Supported API: true
    • setOldGenPercentCollUsageThreshold

      void setOldGenPercentCollUsageThreshold(double oldGenPercentCollUsageThreshold)
      Percent collection usage threshold for old generation memory pool

      Supported API: true
    • getOldGenPercentCollUsage

      double getOldGenPercentCollUsage()
      Current old generation pool percent collection usage

      Supported API: true
    • getOldGenPercentUsagePeak

      double getOldGenPercentUsagePeak()
      Peak old generation pool percent usage

      Supported API: true
    • getHeapPercentUsageThreshold

      double getHeapPercentUsageThreshold()
      Percent overall heap usage threshold

      Supported API: true
    • setHeapPercentUsageThreshold

      void setHeapPercentUsageThreshold(double heapPercentUsageThreshold)
      Percent overall heap usage threshold

      Supported API: true
    • getHeapPercentUsage

      double getHeapPercentUsage()
      Current overall heap percent usage

      Supported API: true
    • getCodeCachePercentUsageThreshold

      double getCodeCachePercentUsageThreshold()
      Percent usage threshold for code cache memory pool

      Supported API: true
    • setCodeCachePercentUsageThreshold

      void setCodeCachePercentUsageThreshold(double codeCachePercentUsageThreshold)
      Percent usage threshold for code cache memory pool

      Supported API: true
    • getCodeCachePercentUsage

      double getCodeCachePercentUsage()
      Current code cache memory pool percent usage

      Supported API: true
    • getCodeCachePercentUsagePeak

      double getCodeCachePercentUsagePeak()
      Peak code cache memory pool percent usage

      Supported API: true
    • getMinAvailableHeapThreshold

      int getMinAvailableHeapThreshold()
      Threshold for minimum number of bytes available on the heap; when less than this number of bytes can be allocated an initial notification is sent to allow listeners to attempt to free up memory. If after this the specified number of bytes is still not available a final notification is sent and then the process is exited via System.exit(). This can be useful to address some JVMs which die very slowly under low or out-of-memory conditions, for instance. A non-positive value of this threshold disables this feature.

      Supported API: true
    • setMinAvailableHeapThreshold

      void setMinAvailableHeapThreshold(int minAvailableHeapThreshold)
      Threshold for minimum number of bytes available on the heap; when less than this number of bytes can be allocated an initial notification is sent to allow listeners to attempt to free up memory. If after this the specified number of bytes is still not available a final notification is sent and then the process is exited via System.exit(). This can be useful to address some JVMs which die very slowly under low or out-of-memory conditions, for instance. A non-positive value of this threshold disables this feature.

      Supported API: true
    • getMinAvailableHeapPercThreshold

      double getMinAvailableHeapPercThreshold()
      Threshold for minimum percentage of heap available; when less than this number of bytes can be allocated an initial notification is sent to allow listeners to attempt to free up memory. If after this the specified number of memory is still not available a final notification is sent and then the process is exited via System.exit(). This can be useful to address some JVMs which die very slowly under low or out-of-memory conditions, for instance. A non-positive value of this threshold disables this feature.

      Supported API: true
    • setMinAvailableHeapPercThreshold

      void setMinAvailableHeapPercThreshold(double minAvailableHeapPercThreshold)
      Threshold for minimum percentage of heap available; when less than this number of bytes can be allocated an initial notification is sent to allow listeners to attempt to free up memory. If after this the specified number of memory is still not available a final notification is sent and then the process is exited via System.exit(). This can be useful to address some JVMs which die very slowly under low or out-of-memory conditions, for instance. A non-positive value of this threshold disables this feature.

      Supported API: true
    • isNoisyStillExceededNotifications

      boolean isNoisyStillExceededNotifications()
      Whether "still exceeded" notifications will be sent frequently (noisily) or rather only at most every CheckIntervalSeconds seconds.

      Supported API: true
    • setNoisyStillExceededNotifications

      void setNoisyStillExceededNotifications(boolean noisyStillExceededNotifications)
      Whether "still exceeded" notifications will be sent frequently (noisily) or rather only at most every CheckIntervalSeconds seconds.

      Supported API: true
    • getCheckIntervalSeconds

      int getCheckIntervalSeconds()
      Interval (in seconds) at which overall heap threshold is checked and other thresholds are adjusted

      Supported API: true
    • setCheckIntervalSeconds

      void setCheckIntervalSeconds(int checkIntervalSeconds)
      Interval (in seconds) at which overall heap threshold is checked and other thresholds are adjusted

      Supported API: true
    • isGCBaitingEnabled

      boolean isGCBaitingEnabled()
      Whether "garbage collection baiting" is explicitly enabled. When enabled, this "baits" the garbage collector with a softly referenced object and checks heap usage whenever the garage collector takes (collects) the bait. This provides more aggressive and adaptive heap usage checking than that obtained simply via CheckIntervalSeconds. Note that garbage collection baiting is implicitly enabled whenever MinAvailableHeapThreshold is positive.

      Supported API: true
    • setGCBaitingEnabled

      void setGCBaitingEnabled(boolean gcBaitingEnabled)
      Whether "garbage collection baiting" is explicitly enabled. When enabled, this "baits" the garbage collector with a softly referenced object and checks heap usage whenever the garage collector takes (collects) the bait. This provides more aggressive and adaptive heap usage checking than that obtained simply via CheckIntervalSeconds. Note that garbage collection baiting is implicitly enabled whenever MinAvailableHeapThreshold is positive.

      Supported API: true