Interface OperatingSystemMXBean
- All Superinterfaces:
-
OperatingSystemMXBean
,PlatformManagedObject
- All Known Subinterfaces:
UnixOperatingSystemMXBean
public interface OperatingSystemMXBean extends OperatingSystemMXBean
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 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. Use getCpuLoad() instead of this historically named method. |
long |
getTotalMemorySize() |
Returns the total amount of memory in bytes. |
default long |
getTotalPhysicalMemorySize() |
Deprecated. Use getTotalMemorySize() instead of this historically named method. |
long |
getTotalSwapSpaceSize() |
Returns the total amount of swap space in bytes. |
Methods declared in interface java.lang.management.OperatingSystemMXBean
getArch, getAvailableProcessors, getName, getSystemLoadAverage, getVersion
Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
Method Details
getCommittedVirtualMemorySize
long getCommittedVirtualMemorySize()
-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.
getFreeSwapSpaceSize
long getFreeSwapSpaceSize()
- Returns:
- the amount of free swap space in bytes.
getProcessCpuTime
long getProcessCpuTime()
-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
@Deprecated(since="14") default long getFreePhysicalMemorySize()
getFreeMemorySize()
instead of this historically named method.- 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.
- Since:
- 14
getTotalPhysicalMemorySize
@Deprecated(since="14") default long getTotalPhysicalMemorySize()
getTotalMemorySize()
instead of this historically named method.- 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.
- Since:
- 14
getSystemCpuLoad
@Deprecated(since="14") default double getSystemCpuLoad()
getCpuLoad()
instead of this historically named method.- 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
getCpuLoad
double getCpuLoad()
- Returns:
- the "recent cpu usage" for the whole operating environment; a negative value if not available.
- Since:
- 14
getProcessCpuLoad
double getProcessCpuLoad()
- Returns:
- the "recent cpu usage" for the Java Virtual Machine process; a negative value if not available.
- Since:
- 1.7
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html
getFreeMemorySize()
instead of this historically named method.