The JVM is a theatre with three departments (Ch 1). The stage crew — class loaders — bring in each class only when a scene first needs it: load the bytecode,
verify it's safe, prepare its static fields, and initialise it once, always asking the parent loader first so core classes can't be faked; a class that's
missing at run time shows up as ClassNotFoundException when asked for by name, or NoClassDefFoundError when it vanished after compiling (Ch 2).
Everything lives in the runtime data areas: every object on the shared heap, class metadata in native metaspace (which replaced PermGen), and each thread's
private stack of frames — which overflowed at depth 47,324 by default and 98,903 with -Xss4m — every object paying a 12-byte header, padded to 8 (Ch 3). The
execution engine first reads the stack-based bytecode line by line, then its JIT compilers learn the hot scenes by heart: C1 quickly with profiling, C2
aggressively — inlining, speculating and deoptimising when wrong, and via escape analysis deleting 50 million allocations outright (Ch 4).
The cleaners — the garbage collector — keep only what can be reached by following strings from the GC roots (stacks, statics, threads), which frees unreachable cycles and makes a Java leak mean "still reachable by mistake" (Ch 5). Because most objects die young, the heap has a casualty ward — Eden and two survivor spaces, where copying the few survivors took under a millisecond while freeing 150 MB — and a long-stay old generation for the promoted (Ch 6). Collectors sweep, compact or copy, and every stop-the-world pause is a moment no request is served, which concurrent collectors shrink at some CPU cost (Ch 7). G1, the default, collects the regions with the most garbage first within a pause target; ZGC keeps pauses under a millisecond at any heap size if given headroom; Parallel maximises throughput (Ch 8). References come as ropes, rubber bands, threads and notes — strong, soft, weak, phantom (Ch 9). And in production, you size the heap as a share of the container, keep GC logs, and use heap dumps, thread dumps and Flight Recorder to explain the pause spikes, the leak and the slow warm-up that started this file (Ch 10).
The last file in this folder, Recursion, returns to the call stack — this time as a problem-solving tool.