Interface OperatingSystemMXBean
- All Superinterfaces:
- OperatingSystemMXBean,- PlatformManagedObject
- All Known Subinterfaces:
- UnixOperatingSystemMXBean
Platform-specific management interface for the operating system
 on which the Java virtual machine is running.
 
This interface provides information about the operating environment on which the Java virtual machine is running. That might be a native operating system, a virtualized operating system environment, or a container-managed environment.
 The OperatingSystemMXBean object returned by
 ManagementFactory.getOperatingSystemMXBean()
 is an instance of the implementation class of this interface
 or UnixOperatingSystemMXBean interface depending on
 its underlying operating system.
- Since:
- 1.5
- 
Method SummaryModifier and TypeMethodDescriptionlongReturns the amount of virtual memory that is guaranteed to be available to the running process in bytes, or-1if this operation is not supported.doubleReturns the "recent CPU usage" for the operating environment.longReturns the amount of free memory in bytes.default longDeprecated.longReturns the amount of free swap space in bytes.doubleReturns the "recent CPU usage" for the Java Virtual Machine process.longReturns the CPU time used by the process on which the Java virtual machine is running in nanoseconds.default doubleDeprecated.UsegetCpuLoad()instead of this historically named method.longReturns the total amount of memory in bytes.default longDeprecated.UsegetTotalMemorySize()instead of this historically named method.longReturns the total amount of swap space in bytes.Methods declared in interface java.lang.management.OperatingSystemMXBeangetArch, getAvailableProcessors, getName, getSystemLoadAverage, getVersionMethods declared in interface java.lang.management.PlatformManagedObjectgetObjectName
- 
Method Details- 
getCommittedVirtualMemorySizelong getCommittedVirtualMemorySize()Returns the amount of virtual memory that is guaranteed to be available to the running process in bytes, or-1if this operation is not supported.- Returns:
- the amount of virtual memory that is guaranteed to
 be available to the running process in bytes,
 or -1if this operation is not supported.
 
- 
getTotalSwapSpaceSizelong getTotalSwapSpaceSize()Returns the total amount of swap space in bytes.- Returns:
- the total amount of swap space in bytes.
 
- 
getFreeSwapSpaceSizelong getFreeSwapSpaceSize()Returns the amount of free swap space in bytes.- Returns:
- the amount of free swap space in bytes.
 
- 
getProcessCpuTimelong getProcessCpuTime()Returns the CPU time used by the process on which the Java virtual machine is running in nanoseconds. The returned value is of nanoseconds precision but not necessarily nanoseconds accuracy. This method returns-1if the the platform does not support this operation.- Returns:
- the CPU time used by the process in nanoseconds,
 or -1if this operation is not supported.
 
- 
getFreePhysicalMemorySizeDeprecated.UsegetFreeMemorySize()instead of this historically named method.Returns the amount of free physical memory in bytes.- Implementation Requirements:
- This implementation must return the same value
 as getFreeMemorySize().
- Returns:
- the amount of free physical memory in bytes.
 
- 
getFreeMemorySizelong getFreeMemorySize()Returns the amount of free memory in bytes.- Returns:
- the amount of free memory in bytes.
- Since:
- 14
 
- 
getTotalPhysicalMemorySizeDeprecated.UsegetTotalMemorySize()instead of this historically named method.Returns the total amount of physical memory in bytes.- Implementation Requirements:
- This implementation must return the same value
 as getTotalMemorySize().
- Returns:
- the total amount of physical memory in bytes.
 
- 
getTotalMemorySizelong getTotalMemorySize()Returns the total amount of memory in bytes.- Returns:
- the total amount of memory in bytes.
- Since:
- 14
 
- 
getSystemCpuLoadDeprecated.UsegetCpuLoad()instead of this historically named method.Returns the "recent CPU usage" for the whole system. This value is a double in the [0.0,1.0] interval. A value of 0.0 means that all CPUs were idle during the recent period of time observed, while a value of 1.0 means that all CPUs were actively running 100% of the time during the recent period being observed. The recent period of observation is implementation-specific, and typically relates to the duration since the last call made to this method, orgetCpuLoad(). For the very first invocation, the recent period of observation is undefined. All values between 0.0 and 1.0 are possible dependent on the activities going on. If the recent CPU usage is not available, the method returns a negative value.- API Note:
- Callers should be aware of the possibility of other callers affecting the observation period and the result.
- Implementation Requirements:
- This implementation must return the same value
 as getCpuLoad().
- Returns:
- the "recent cpu usage" for the whole system; a negative value if not available.
- Since:
- 1.7
 
- 
getCpuLoaddouble getCpuLoad()Returns the "recent CPU usage" for the operating environment. This value is a double in the [0.0,1.0] interval. A value of 0.0 means that all CPUs were idle during the recent period of time observed, while a value of 1.0 means that all CPUs were actively running 100% of the time during the recent period being observed. The recent period of observation is implementation-specific, and typically relates to the duration since the last call made to this method, orgetSystemCpuLoad(). For the very first invocation, the recent period of observation is undefined. All values between 0.0 and 1.0 are possible dependent on the activities going on. If the recent CPU usage is not available, the method returns a negative value.- API Note:
- Callers should be aware of the possibility of other callers affecting the observation period and the result.
- Returns:
- the "recent cpu usage" for the whole operating environment; a negative value if not available.
- Since:
- 14
 
- 
getProcessCpuLoaddouble getProcessCpuLoad()Returns the "recent CPU usage" for the Java Virtual Machine process. This value is a double in the [0.0,1.0] interval. A value of 0.0 means that none of the CPUs were running threads from the JVM process during the recent period of time observed, while a value of 1.0 means that all CPUs were actively running threads from the JVM 100% of the time during the recent period being observed. Threads from the JVM include the application threads as well as the JVM internal threads. The recent period of observation is implementation-specific, and typically relates to the duration since the last call made to this method. For the very first invocation, the recent period of observation is undefined. All values between 0.0 and 1.0 are possible dependent on the activities going on in the JVM process and the whole system. If the Java Virtual Machine recent CPU usage is not available, the method returns a negative value.- API Note:
- Callers should be aware of the possibility of other callers affecting the observation period and the result.
- Returns:
- the "recent cpu usage" for the Java Virtual Machine process; a negative value if not available.
- Since:
- 1.7
 
 
- 
getFreeMemorySize()instead of this historically named method.