liveBook · Manning

GC event

As explained in Troubleshooting Java, Second Edition

A GC event is a recorded garbage-collection operation with a type, phases, timing information, and changes to heap regions or objects.

A GC event is a recorded garbage-collection operation. Its log identifies the collection type, reports work performed in phases, measures timing, and shows how heap regions changed afterward. section 11.1

Read a GC event by checking:

  • The collection kind, such as a G1 young evacuation pause. section 11.1
  • The phases and their durations, including evacuation and other work. section 11.1
  • The heap-region transitions: Eden, Survivor, Old, and Humongous regions before and after collection. section 11.1

Enable and inspect an event

Run an application with `java -Xlog:gc* -jar app.jar`. A typical event begins with `GC(0)` and identifies a young G1 evacuation pause, its worker count and phases, then reports changes such as Eden `4->0` and Survivor `0->1`. section 11.1

Listing 11.2 Logs related to events of a GC event of memory collecting
[1.336s][info][gc,start] GC(0) 
   ➥ Pause Young (Normal)(G1 Evacuation Pause)    #1

[1.337s][info][gc,task] GC(0) 
   ➥ Using 8 workers of 8 for evacuation    #2

[1.342s][info][gc,phases] GC(0)   
   ➥ Pre Evacuate Collection Set: 0.13ms    #3

[1.342s][info][gc,phases] GC(0)   
   ➥ Merge Heap Roots: 0.20ms      #4

[1.342s][info][gc,phases] GC(0)   
   ➥ Evacuate Collection Set: 4.04ms      #5

[1.342s][info][gc,phases] GC(0)   
   ➥ Post Evacuate Collection Set: 0.73ms     #6
[1.342s][info][gc,phases] GC(0) Other: 0.71ms

Inspect a concrete event log showing collection type, worker activity, phase durations, and elapsed time. section 11.1

How Troubleshooting Java, Second Edition covers it

How deep it goes
Breaks events into types, phases, timings, and heap-region changes, without extending beyond log interpretation.
Examples
Uses `-Xlog:gc*`, a Java launch command, G1 initialization output, and detailed collection and region-transition logs.
What you can do after
Diagnose/debug with it by enabling GC logs and relating collection pauses, phases, and heap-region changes to memory behavior.
How it connects
Connects garbage collection with GC logs, heap regions, G1, Eden, Survivor, and old generation.

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.