Part 7 · Fundamentals

JVM, JIT, garbage collection and diagnosis

Prerequisites: 01-ecosystem

How do execution and evidence connect?

Bytecode: loaded methods; Interpreter: execute + profile; JIT compilation: hot methods; Heap / GC: allocation + reclamation; JFR recording: runtime evidence. Connections: Bytecode to Interpreter (execute); Interpreter to JIT compilation (hot code); Interpreter to JFR recording (events); Heap / GC to JFR recording (events)
Simplified HotSpot view. JFR includes additional event categories; GC and compilation may run concurrently. [S14] [S15]

Goal & mental model verified

HotSpot starts with interpretation and adaptively compiles hot code. Garbage collection manages object memory. Flight Recorder captures runtime events for diagnosis; request latency can include CPU, allocation, locks and external waiting.

[S14] [S15]

Worked example · design exercise synthesis

A quote endpoint’s latency rises while CPU stays modest. A recording and dependency timings may reveal contention or connection waits rather than expensive Java computation.

[S14] [S15]

Engineering decision synthesis

Choose a runtime and collector against workload and deployment limits. Compare warm steady-state behavior and startup separately; a microbenchmark rarely predicts full service latency.

[S14] [S15]

Pitfall & diagnosis synthesis

Treating every pause as a GC problem can hide a slow database. Increasing heap can reduce some collection pressure while increasing footprint and changing pause behavior.

[S14] [S15]

Improve & validate synthesis

Form a hypothesis, capture JFR plus service metrics, change one factor, then repeat representative load. Keep the measurement environment and warm-up conditions explicit.

[S14] [S15]
Keep this: Observe the bottleneck before tuning the JVM.
Check yourself: Can low CPU coexist with high latency?

Yes. A request may be waiting for a lock, I/O or a scarce connection.

Sources & further reading

  1. [S14] HotSpot technology overview

    Oracle / OpenJDK · documentation · accessed 2026-10-09 · Java SE 25

    Supports: Interpreter and adaptive compilation; Garbage collection

    Read the linked section to validate the mechanism and its version-specific constraints.

  2. [S15] Flight Recorder guide

    Oracle / OpenJDK · documentation · accessed 2026-10-09 · Java SE 25

    Supports: JFR events and recordings for runtime diagnosis

    Read the linked section to validate the mechanism and its version-specific constraints.