-
CSR
-
Resolution: Unresolved
-
P4
-
None
-
None
-
minimal
-
There should no compatibility risk since this introduces a new method into java.lang.management.MemoryMXBean.
-
Java API
-
JDK
Summary
Add method java.lang.management.MemoryMXBean.GetGcCpuTime(). This method returns the CPU time in nanoseconds for all GC related threads and the GC related operations on the VM thread.
Problem
The VM supports retrieval of GC CPU time since JDK 26 (JDK-8359110) and logs these values via -Xlog:cpu during VM shutdown. To support a refined understanding, during critical sections, of GC CPU time, sampling this at will would be needed. There is no viable alternative to sample this from Java application code today. This will complement getProcessCpuTime() from OperatingSystemMXBean.
Solution
Introduce a new method, java.lang.management.MemoryMXBean.GetGcCpuTime().
Specification
/**
* Returns the CPU time used by all garbage collection threads.
*
* <p> This include time since genesis, so the value can be
* non-zero even if no garbage collection cycles occured. In
* general this includes time for all driver threads,
* workers, VM operations on the VM thread and the string
* deduplication thread (if enabled). This method returns
* {@code -1} if the platform does not support this operation
* or if called during shutdown.
*
* @return the total CPU time for all garbage collection
* threads in nanoseconds.
*
* @since 26
*/
public long getGcCpuTime();
- csr of
-
JDK-8368527 JMX: Add an MXBeans method to query GC CPU time
-
- New
-