Java 8 GC Tutorials - Herong's Tutorial Examples - v1.03, by Dr. Herong Yang
"-XX:+PrintTenuringDistribution" - Tunuring Distribution
This section describes the garbage collection logging option, '-XX:+PrintTenuringDistribution', which prints the tenuring distribution of objects in the survivor space after each Minor GC.
In this tutorial, let's try the "-XX:+PrintTenuringDistribution" garbage collection logging option to see what we will get in the log file:
herong> \progra~1\java\jdk1.8.0\bin\java -Xms2m -Xmx64m \
-XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC \
-XX:+PrintGCDetails -Xloggc:gc.log GarbageCollection
Step/TotalMemory/FreeMemory/UsedMemory:
1 2031616 698408 1333208
2 3874816 1472824 2401992
3 3874816 424944 3449872
4 8970240 4441352 4528888
5 8970240 3358312 5611928
...
(Ctrl-C)
herong> more gc.log
{Heap before GC invocations=0 (full 0):
def new generation total 960K, used 878K [...
eden space 896K, 98% used [...
from space 64K, 0% used [...
to space 64K, 0% used [...
tenured generation total 1024K, used 0K [...
the space 1024K, 0% used [...
Metaspace used 1555K, capacity 2242K, committed 2368K, reserved 4480K
0.104: [GC (Allocation Failure) 0.104: [DefNew
Desired survivor size 32768 bytes, new threshold 1 (max 15)
- age 1: 65536 bytes, 65536 total
-- First group of objects with age of 1 identified
: 878K->64K(960K), 0.0010261 secs] 878K->756K(1984K), 0.0011489 secs]
Heap after GC invocations=1 (full 0):
def new generation total 960K, used 64K [...
eden space 896K, 0% used [...
from space 64K, 100% used [...
to space 64K, 0% used [...
tenured generation total 1024K, used 692K [...
the space 1024K, 67% used [...
Metaspace used 1555K, capacity 2242K, committed 2368K, reserved 4480K
}
{Heap before GC invocations=1 (full 0):
def new generation total 960K, used 865K [...
eden space 896K, 89% used [...
from space 64K, 100% used [...
to space 64K, 0% used [...
tenured generation total 1024K, used 692K [...
the space 1024K, 67% used [...
Metaspace used 1555K, capacity 2242K, committed 2368K, reserved 4480K
1.109: [GC (Allocation Failure) 1.109: [DefNew
Desired survivor size 32768 bytes, new threshold 1 (max 15)
- age 1: 65536 bytes, 65536 total
-- Second group of objects with age of 1 identified
-- The previous group has been promoted to the "tenure"
: 865K->64K(960K), 0.0013277 secs]
1.111: [Tenured: 1476K->1539K(1540K), 0.0013836 secs]
1557K->1540K(2500K), ...
Heap after GC invocations=2 (full 1):
def new generation total 1216K, used 0K [...
eden space 1088K, 0% used [...
from space 128K, 0% used [...
to space 128K, 0% used [...
tenured generation total 2568K, used 1539K [...
the space 2568K, 59% used [...
Metaspace used 1555K, capacity 2242K, committed 2368K, reserved 4480K
}
...
The "-XX:+PrintTenuringDistribution" prints two messages after each minor GC:
Table of Contents
Heap Memory Area and Size Control
►JVM Garbage Collection Logging
Garbage Collection Demo Program
Garbage Collection Logging Options
"-XX:+PrintGC" - GC Logging Option for Short Messages
"-XX:+PrintGCDetails" - Option for Detailed GC Messages
"-XX:+PrintGCDateStamps" - Calendar Timestamp on GC Messages
"-XX:+PrintGCApplicationStoppedTime" - Application Pause Durations
"-XX:+PrintGCApplicationConcurrentTime" - Application Running Durations
"-XX:+PrintHeapAtGC" - Print Heap Summary per GC
►"-XX:+PrintTenuringDistribution" - Tunuring Distribution
"-XX:+PrintReferenceGC" - Reference Counts per GC
"-XX:+PrintFlagsFinal" - Print JVM Options
Introduction of Garbage Collectors
Serial Collector - "+XX:+UseSerialGC"
Parallel Collector - "+XX:+UseParallelGC"
Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"
Garbage First (G1) Collector - "+XX:+UseG1GC"
Object References and Garbage Collection
Garbage Collection Performance Test Program
Performance Tests on Serial Collector
Performance Tests on Parallel collector
Performance Tests on Concurrent collector
Performance Tests on G1 collector