APIdia Launch Partner
Top Description Methods
com.sun.management

public Interface OperatingSystemMXBean

extends OperatingSystemMXBean
Known Direct Subinterfaces
com.sun.management.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 java.lang.management.ManagementFactory#getOperatingSystemMXBean() is an instance of the implementation class of this interface or UnixOperatingSystemMXBean interface depending on its underlying operating system.

Author
Mandy Chung
Since
1.5

Method Summary

Modifier and TypeMethod and Description
public long

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.
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.

public double

Returns:

the "recent cpu usage" for the whole operating environment; a negative value if not available.
getCpuLoad
()

Returns the "recent CPU usage" for the operating environment.

public long

Returns:

the amount of free memory in bytes.
getFreeMemorySize
()

Returns the amount of free memory in bytes.

public default long

Returns:

the amount of free physical memory in bytes.
getFreePhysicalMemorySize
()
Deprecated since 14. Use getFreeMemorySize() instead of this historically named method.

Returns the amount of free physical memory in bytes.

public long

Returns:

the amount of free swap space in bytes.
getFreeSwapSpaceSize
()

Returns the amount of free swap space in bytes.

public double

Returns:

the "recent cpu usage" for the Java Virtual Machine process; a negative value if not available.
getProcessCpuLoad
()

Returns the "recent CPU usage" for the Java Virtual Machine process.

public long

Returns:

the CPU time used by the process in nanoseconds, or -1 if this operation is not supported.
getProcessCpuTime
()

Returns the CPU time used by the process on which the Java virtual machine is running in nanoseconds.

public default double

Returns:

the "recent cpu usage" for the whole system; a negative value if not available.
getSystemCpuLoad
()
Deprecated since 14. Use getCpuLoad() instead of this historically named method.

Returns the "recent CPU usage" for the whole system.

public long

Returns:

the total amount of memory in bytes.
getTotalMemorySize
()

Returns the total amount of memory in bytes.

public default long

Returns:

the total amount of physical memory in bytes.
getTotalPhysicalMemorySize
()
Deprecated since 14. Use getTotalMemorySize() instead of this historically named method.

Returns the total amount of physical memory in bytes.

public long

Returns:

the total amount of swap space in bytes.
getTotalSwapSpaceSize
()

Returns the total amount of swap space in bytes.

Inherited from java.lang.management.OperatingSystemMXBean:
getArchgetAvailableProcessorsgetNamegetSystemLoadAveragegetVersion

Method Detail

getCommittedVirtualMemorySizeback to summary
public 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:long

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.

getCpuLoadback to summary
public 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. The recent period of observation is implementation-specific, and typically relates to the duration since the last call made to this method, or getSystemCpuLoad(). 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:double

the "recent cpu usage" for the whole operating environment; a negative value if not available.

Since
14
getFreeMemorySizeback to summary
public long getFreeMemorySize()

Returns the amount of free memory in bytes.

Returns:long

the amount of free memory in bytes.

Since
14
getFreePhysicalMemorySizeback to summary
public default long getFreePhysicalMemorySize()

Deprecated

since 14.

Use getFreeMemorySize() instead of this historically named method.

Returns the amount of free physical memory in bytes.

Implementation Specification

This implementation must return the same value as getFreeMemorySize().

Returns:long

the amount of free physical memory in bytes.

Annotations
@Deprecated
since:14
getFreeSwapSpaceSizeback to summary
public long getFreeSwapSpaceSize()

Returns the amount of free swap space in bytes.

Returns:long

the amount of free swap space in bytes.

getProcessCpuLoadback to summary
public 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. 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:double

the "recent cpu usage" for the Java Virtual Machine process; a negative value if not available.

Since
1.7
getProcessCpuTimeback to summary
public 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:long

the CPU time used by the process in nanoseconds, or -1 if this operation is not supported.

getSystemCpuLoadback to summary
public default double getSystemCpuLoad()

Deprecated

since 14.

Use getCpuLoad() 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, or getCpuLoad(). 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 Specification

This implementation must return the same value as getCpuLoad().

Returns:double

the "recent cpu usage" for the whole system; a negative value if not available.

Annotations
@Deprecated
since:14
Since
1.7
getTotalMemorySizeback to summary
public long getTotalMemorySize()

Returns the total amount of memory in bytes.

Returns:long

the total amount of memory in bytes.

Since
14
getTotalPhysicalMemorySizeback to summary
public default long getTotalPhysicalMemorySize()

Deprecated

since 14.

Use getTotalMemorySize() instead of this historically named method.

Returns the total amount of physical memory in bytes.

Implementation Specification

This implementation must return the same value as getTotalMemorySize().

Returns:long

the total amount of physical memory in bytes.

Annotations
@Deprecated
since:14
getTotalSwapSpaceSizeback to summary
public long getTotalSwapSpaceSize()

Returns the total amount of swap space in bytes.

Returns:long

the total amount of swap space in bytes.