⚙️ JVM Internals & Memory
16 Java concepts, each explained step by step with real code, a common trap and practice questions.
- JVM architectureClass loader subsystem, runtime data areas, execution engine.
- Class loadingBootstrap, platform and application loaders; parent delegation; loading, linking, initialization.
- When a class is initializedLazy initialization on first active use; static init order.
- Runtime memory areasHeap, stacks, metaspace, PC register, native method stack.
- Stack vs heapFrames and locals on the stack, objects on the heap; escape analysis.
- Reachability & GC rootsObjects alive if reachable from roots; cycles are still collected.
- Generational GCYoung (eden, survivors) and old generations; minor vs major collections.
- Garbage collectorsSerial, Parallel, G1 (default), ZGC, Shenandoah and their trade-offs.
- Reference typesStrong, soft, weak, phantom references; WeakHashMap; Cleaner.
- Memory leaks in JavaStatic collections, listeners, caches, ThreadLocals, inner classes.
- OutOfMemoryError typesJava heap space, Metaspace, GC overhead limit, unable to create native thread.
- JIT compilationInterpreter, C1/C2 tiered compilation, hot spots, inlining, deoptimization.
- Bytecode & javapStack-based instructions, invokevirtual/invokestatic/invokeinterface/invokedynamic.
- JVM flags & tuning basics-Xms, -Xmx, -Xss, choosing a GC, container awareness.
- Diagnostic toolsjcmd, jstack, jmap, JDK Flight Recorder, Mission Control, heap dumps.
- Object layout & headersObject headers, alignment, compact object headers in Java 25.