-
- All Superinterfaces:
PlatformManagedObject
public interface SystemResourcePressureMXBean extends PlatformManagedObject
When using Cooperative Memory Management, theSystemResourcePressureMXBean
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
. TheObjectName
for uniquely identifying theSystemResourcePressureMXBean
within anMBeanServer
is:"com.oracle.management:type=ResourcePressureMBean"
. It can be obtained by calling thePlatformManagedObject.getObjectName()
method.Notifications
ASystemResourcePressureMXBean
implementation must be aNotificationEmitter
, 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 ownNotificationListener
.Registration
Code similar to the following should be used to register this MXBean:
Note that because Cooperative Memory Management is a commercial feature, in order to use it the VM must be running withSystemResourcePressureMXBean mxbean = ManagementFactory.getPlatformMXBean(SystemResourcePressureMXBean.class); ManagementFactory.getPlatformMBeanServer().registerMBean(mxbean, mxbean.getObjectName());
-XX:+UnlockCommercialFeatures
. Otherwise,ManagementFactory.getPlatformMXBean(java.lang.Class<T>)
will throw anIllegalArgumentException
.- Since:
- 8u40
- See Also:
ManagementFactory.getPlatformMXBean(java.lang.Class<T>)
,MBeanServer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getMemoryPressure()
Gets the current memory pressure level.void
setMemoryPressure(int pressureLevel)
Sets the current memory pressure level.-
Methods inherited from interface java.lang.management.PlatformManagedObject
getObjectName
-
-
-
-
Method Detail
-
getMemoryPressure
int getMemoryPressure()
Gets the current memory pressure level.- Returns:
- The current memory pressure level
-
setMemoryPressure
void setMemoryPressure(int pressureLevel)
Sets the current memory pressure level. TheMemoryPressure
attribute can take values from0
through10
, where0
indicates very little memory pressure and10
means the system is very low on memory. If the current memory pressure level is already atpressureLevel
, no action is taken and no notifications are sent.- Parameters:
pressureLevel
- A level from 0-10 inclusive- Throws:
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").
-
-