OperatingSystemMXBean (Java SE 15 & JDK 15) (original) (raw)
All Superinterfaces:
[OperatingSystemMXBean](../../../../java.management/java/lang/management/OperatingSystemMXBean.html "interface in java.lang.management")
, [PlatformManagedObject](../../../../java.management/java/lang/management/PlatformManagedObject.html "interface in java.lang.management")
All Known Subinterfaces:
[UnixOperatingSystemMXBean](UnixOperatingSystemMXBean.html "interface in com.sun.management")
public interface OperatingSystemMXBean extends OperatingSystemMXBean
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 byManagementFactory.getOperatingSystemMXBean() is an instance of the implementation class of this interface or UnixOperatingSystemMXBean interface depending on its underlying operating system.
Since:
1.5
Method Summary
Modifier and Type | Method | Description |
---|---|---|
long | getCommittedVirtualMemorySize() | Returns the amount of virtual memory that is guaranteed to be available to the running process in bytes, or -1 if this operation is not supported. |
double | getCpuLoad() | Returns the "recent cpu usage" for the operating environment. |
long | getFreeMemorySize() | Returns the amount of free memory in bytes. |
default long | getFreePhysicalMemorySize() | Deprecated. |
long | getFreeSwapSpaceSize() | Returns the amount of free swap space in bytes. |
double | getProcessCpuLoad() | Returns the "recent cpu usage" for the Java Virtual Machine process. |
long | getProcessCpuTime() | Returns the CPU time used by the process on which the Java virtual machine is running in nanoseconds. |
default double | getSystemCpuLoad() | Deprecated. |
long | getTotalMemorySize() | Returns the total amount of memory in bytes. |
default long | getTotalPhysicalMemorySize() | Deprecated. |
long | getTotalSwapSpaceSize() | Returns the total amount of swap space in bytes. |
Method Details
getCommittedVirtualMemorySize
long getCommittedVirtualMemorySize()
Returns the amount of virtual memory that is guaranteed to be available to the running process in bytes, or-1
if this operation is not supported.
Returns:
the amount of virtual memory that is guaranteed to be available to the running process in bytes, or-1
if this operation is not supported.getTotalSwapSpaceSize
long getTotalSwapSpaceSize()
Returns the total amount of swap space in bytes.
Returns:
the total amount of swap space in bytes.getFreeSwapSpaceSize
long getFreeSwapSpaceSize()
Returns the amount of free swap space in bytes.
Returns:
the amount of free swap space in bytes.getProcessCpuTime
long 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-1
if the the platform does not support this operation.
Returns:
the CPU time used by the process in nanoseconds, or-1
if this operation is not supported.getFreePhysicalMemorySize
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.getFreeMemorySize
long getFreeMemorySize()
Returns the amount of free memory in bytes.
Returns:
the amount of free memory in bytes.
Since:
14getTotalPhysicalMemorySize
@Deprecated(since="14")default long getTotalPhysicalMemorySize()
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.getTotalMemorySize
long getTotalMemorySize()
Returns the total amount of memory in bytes.
Returns:
the total amount of memory in bytes.
Since:
14getSystemCpuLoad
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. All values betweens 0.0 and 1.0 are possible depending of the activities going on in the system. If the system recent cpu usage is not available, the method returns a negative value.
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.7getCpuLoad
double 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. All values betweens 0.0 and 1.0 are possible depending of the activities going on. If the recent cpu usage is not available, the method returns a negative value.
Returns:
the "recent cpu usage" for the whole operating environment; a negative value if not available.
Since:
14getProcessCpuLoad
double 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. All values betweens 0.0 and 1.0 are possible depending of 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.
Returns:
the "recent cpu usage" for the Java Virtual Machine process; a negative value if not available.
Since:
1.7