Quality Outreach Heads-up - Separate Metaspace and GC Printing

The OpenJDK Quality Group is promoting the testing of FOSS projects with OpenJDK builds as a way to improve the overall quality of the release. This heads-up is part of the quality outreach sent to the projects involved. To learn more about the program, and how-to join, please check here.

Separate Metaspace and GC Printing

Historically the printing of Metaspace and GC logs have been combined, this was a result of permanent generation (PermGen) being a part of the GC Heap. However Metaspace has replaced PermGen and resides in its own native memory location outside of the GC Heap. With Metaspace no longer a part of the GC Heap, the reason for combining the messaging no longer makes sense and could lead to confusion.

Starting with JDK 25, the way logging is tagged in the HotSpot JVM will change: although the content and level (i.e., info or debug) of the logs will remain the same, messages related to Metaspace will now use the existing metaspace tag. This example demonstrates the change:

$ java -Xlog:gc*=debug ...

Before

[1,370s][debug][gc,heap     ] GC(0) Y: Heap before GC invocations=0 (full 0):
[1,370s][debug][gc,heap     ] GC(0) Y:  ZHeap           used 862M, capacity 862M, max capacity 9216M
[1,370s][debug][gc,heap     ] GC(0) Y:   Cache          0M (0)
[1,370s][debug][gc,heap     ] GC(0) Y:  Metaspace       used 18720K, committed 19008K, reserved 1114112K
[1,370s][debug][gc,heap     ] GC(0) Y:   class space    used 1611K, committed 1728K, reserved 1048576K

After:

[1,039s][debug][gc,heap     ] GC(0) Y: Heap Before GC invocations=0 (full 0):
[1,039s][debug][gc,heap     ] GC(0) Y:  ZHeap           used 860M, capacity 860M, max capacity 9216M
[1,039s][debug][gc,heap     ] GC(0) Y:   Cache          0M (0)
[1,039s][debug][gc,metaspace] GC(0) Y: Metaspace Before GC invocations=0 (full 0):
[1,039s][debug][gc,metaspace] GC(0) Y:  Metaspace       used 18674K, committed 19008K, reserved 1114112K
[1,039s][debug][gc,metaspace] GC(0) Y:   class space    used 1601K, committed 1728K, reserved 1048576K

jcmd Update

As part of this update, there are also some user-facing changes to jcmd. To better clarify that Metaspace is not part of the GC Heap, Metaspace information is no longer displayed with the GC.heap_info command. Instead, details about Metaspace memory usage have been moved to the VM.metaspace. The below examples demonstrate this change:

Before:

$ jcmd SourceLauncher GC.heap_info
71420:
 ZHeap           used 96M, capacity 576M, max capacity 9216M
  Cache          480M (1)
   size classes  256M (1)
 Metaspace       used 18155K, committed 18496K, reserved 1114112K
  class space    used 1536K, committed 1664K, reserved 1048576K

$ jcmd SourceLauncher VM.metaspace
71420:

Total Usage - 125 loaders, 2860 classes:
...

After:

$ jcmd SourceLauncher GC.heap_info
21832:
ZHeap            used 96M, capacity 576M, max capacity 9216M
 Cache           480M (1)
  size classes   256M (1)

$ jcmd SourceLauncher VM.metaspace
21832:
Metaspace        used 18134K, committed 18432K, reserved 1114112K
 class space     used 1519K, committed 1664K, reserved 1048576K

Total Usage - 125 loaders, 2834 classes:
...

This update has been incorporated into the 25-ea mainline build available here. For more details on this change, check the JBS issue: JDK-8356938. Any feedback should be reported to the hotspot-dev mailing list.

~