Glossary#
| Term | Plain meaning | Chapter |
|---|---|---|
| HotSpot | the standard JVM implementation | 1 |
| class loader / parent delegation | loads classes / ask the parent first | 2 |
| loading / linking (verify, prepare, resolve) / initialisation | class loading phases | 2 |
| ClassNotFoundException / NoClassDefFoundError | requested-by-name class missing / compiled-against class missing at run time | 2 |
| heap / metaspace / PermGen | objects / class metadata (native) / the pre-Java-8 area | 3 |
| JVM stack / frame / PC register | per-thread call stack / one call / current instruction | 3 |
| code cache | stores JIT-compiled machine code | 3 |
| object header / mark word / compressed oops | per-object overhead / hash, lock, age bits / 32-bit references | 3 |
| humongous object | a G1 object ≥ half a region | 3, 8 |
| bytecode / operand stack / javap | JVM instructions / their working stack / the disassembler | 4 |
| interpreter / JIT / C1 / C2 / tiered compilation | execution modes and compilers | 4 |
| inlining / deoptimisation / escape analysis / scalar replacement | JIT optimisations | 4 |
| warm-up / CDS / GraalVM Native Image | slow start / faster start-up data / ahead-of-time compilation | 4 |
| GC root / reachable / live / garbage | starting points / found by tracing / kept / freed | 5 |
| reference counting | counting references per object; can't free cycles | 5 |
| generational hypothesis | most objects die young | 6 |
| Eden / survivor (S0, S1) / old generation | new objects / young survivors / long-lived | 6 |
| minor / major / full GC | young / old / everything | 6 |
| tenuring threshold / promotion / premature promotion | survivals before moving to old / the move / moving too early | 6 |
| TLAB | per-thread allocation chunk in Eden | 6 |
| mark–sweep / mark–compact / copying | GC algorithms | 7 |
| stop-the-world / concurrent collection / barrier | pause everything / GC alongside the app / tracking code | 7 |
| throughput / latency | time not spent in GC / pause length | 7 |
| Serial / Parallel / G1 / ZGC / Shenandoah / Epsilon | the collectors | 8 |
| region / mixed GC / pause target | G1's heap unit / young + chosen old regions / MaxGCPauseMillis | 8 |
| allocation stall | allocating faster than concurrent GC frees | 8 |
| strong / soft / weak / phantom reference | reference strengths | 9 |
| Cleaner / finalize | modern clean-up hook / deprecated old one | 9 |
| -Xms / -Xmx / -Xss / MaxRAMPercentage | initial heap / max heap / stack size / heap as % of RAM | 10 |
| heap dump / thread dump / JFR / MAT | object snapshot / thread stacks / flight recorder / dump analyser | 10 |
| dominator tree / path to GC roots | what retains the most / why it's alive | 10 |
Cheat Sheet#
Memory map
shared: HEAP [ young: Eden | S0 | S1 ][ old ] METASPACE (native) CODE CACHE
per thread: STACK (frames: locals, operand stack) PC register native stack
errors: heap space OOM · Metaspace OOM · StackOverflowError · (container) OOMKilled 137GC in one breath
mark from roots → young GC copies survivors (cheap: cost ∝ live) → promote after N survivals → old gen collected rarely
G1 default (regions, garbage-first, ~200 ms target) · ZGC sub-ms (needs headroom) · Parallel for throughputFlags
-Xms2g -Xmx2g · -XX:MaxRAMPercentage=75 (containers) · -Xss1m · -XX:+UseZGC · -XX:MaxGCPauseMillis=100
-Xlog:gc*:file=gc.log · -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/dumps · -XX:+PrintCommandLineFlagsTools
jcmd <pid> GC.heap_info | GC.heap_dump f.hprof | Thread.print | JFR.start duration=60s filename=r.jfr
jstat -gc <pid> 1000 · jstack <pid> · javap -c -p Foo.class · Eclipse MAT · JDK Mission Control · VisualVMRead a GC log line
GC(2) Pause Young (Normal) (G1 Evacuation Pause) 153M->1M(256M) 0.977ms
kind of pause cause before->after(heap size) pause lengthTry This Yourself#
Read your own bytecode. Compile any method from Java Basics, run
javap -c -p, and annotate each instruction like Ch 4. Find where aforloop jumps backwards.Watch generations. Run the 3-million-notes program with
-Xmx256m -Xlog:gc, then change it to keep 1 in 10 notes instead of 1 in 1,000. How do the "after" sizes and pause times change? Do you seePause Young (Mixed)or a full GC?Make and find a leak. Write a service loop that stores every "request" in a static
Listand never removes them. Run with-Xmx128m -XX:+HeapDumpOnOutOfMemoryError, open the dump in Eclipse MAT (free), and find the static list in the dominator tree and its path to GC roots.Compare collectors. Run the same allocation-heavy program with
-XX:+UseSerialGC,-XX:+UseParallelGC,-XX:+UseG1GCand-XX:+UseZGC(with a generous heap, e.g.-Xmx1g), and compare total time and the longest pause in each log.