- All Superinterfaces:
MemoryMXBean
,PlatformManagedObject
Platform-specific management interface for a garbage collector
which performs collections in cycles.
GarbageCollectorMXBean is an interface used by the management system to access garbage collector properties and reset the values of associated counter and accumulator properties.
This platform extension is only available to the garbage collection implementation that supports this extension.
- Since:
- 18
-
Method Summary
Modifier and TypeMethodDescriptiondefault long
Returns an approximation of the total amount of memory, in bytes, allocated in Java object heap memory since the start of JVM execution.default String
Version of the MemoryMXBean application programming interface.Methods declared in interface java.lang.management.MemoryMXBean
gc, getHeapMemoryUsage, getNonHeapMemoryUsage, getObjectPendingFinalizationCount, isVerbose, setVerbose
Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
-
Method Details
-
getVersion
Version of the MemoryMXBean application programming interface. The format for the version is majorVersion.minorVersion.microVersion.- Returns:
- the version of the MemoryMXBean application programming interface; the null string if no version information is available.
-
getAllocatedBytes
default long getAllocatedBytes()Returns an approximation of the total amount of memory, in bytes, allocated in Java object heap memory since the start of JVM execution. The returned value is an approximation because some Java virtual machine implementations may use object allocation mechanisms that result in a delay between the time an object is allocated and the time its size is recorded.- Returns:
- an approximation of the total memory allocated, in bytes, in
Java object heap memory since the start of JVM execution, if
memory allocation measurement is enabled;
-1
otherwise. - Throws:
UnsupportedOperationException
- if the Java virtual machine implementation does not support memory allocation measurement.
-