Interface SystemResourcePressureMXBean

  • All Superinterfaces:

    public interface SystemResourcePressureMXBean
    extends PlatformManagedObject
    When using Cooperative Memory Management, the SystemResourcePressureMXBean serves to communicate memory pressure to the VM. Memory pressure represents the total memory usage (RAM) on the system. The higher the pressure, the closer you are to running out of memory.

    A Java virtual machine can have at most one instance of a SystemResourcePressureMXBean. The ObjectName for uniquely identifying the SystemResourcePressureMXBean within an MBeanServer is: "". It can be obtained by calling the PlatformManagedObject.getObjectName() method.


    A SystemResourcePressureMXBean implementation must be a NotificationEmitter, to allow one or more notification listeners to be registered for receiving a notification when the memory pressure changes.

    This MXBean will emit an AttributeChangeNotification when the memory pressure is changed. Applications can react to memory pressure by adding their own NotificationListener.


    Code similar to the following should be used to register this MXBean:

         SystemResourcePressureMXBean mxbean =
         ManagementFactory.getPlatformMBeanServer().registerMBean(mxbean, mxbean.getObjectName());
    Note that because Cooperative Memory Management is a commercial feature, in order to use it the VM must be running with -XX:+UnlockCommercialFeatures. Otherwise, ManagementFactory.getPlatformMXBean(java.lang.Class<T>) will throw an IllegalArgumentException.
    See Also:
    ManagementFactory.getPlatformMXBean(java.lang.Class<T>), MBeanServer
    • Method Detail

      • getMemoryPressure

        int getMemoryPressure​()
        Gets the current memory pressure level.
        The current memory pressure level
      • setMemoryPressure

        void setMemoryPressure​(int pressureLevel)
        Sets the current memory pressure level. The MemoryPressure attribute can take values from 0 through 10, where 0 indicates very little memory pressure and 10 means the system is very low on memory. If the current memory pressure level is already at pressureLevel, no action is taken and no notifications are sent.
        pressureLevel - A level from 0-10 inclusive
        IllegalArgumentException - if the pressureLevel provided is outside the range of 0-10 inclusive.
        SecurityException - if a security manager exists and the caller does not have ManagementPermission("control").