Fundamentals 9 min read

Overview of Java Virtual Machine Architecture, Garbage Collection, and Class Loading

This article provides a comprehensive overview of the Java Virtual Machine (JVM) architecture, detailing its garbage collection mechanisms, class‑loader subsystem, execution engine, runtime data areas, and common GC command‑line options, offering essential knowledge for Java developers.

Big Data Technology & Architecture
Big Data Technology & Architecture
Big Data Technology & Architecture
Overview of Java Virtual Machine Architecture, Garbage Collection, and Class Loading

The Java Virtual Machine (JVM) is a software implementation of a computer that runs Java bytecode; source files (.java) are compiled by javac into .class files, which the JVM loads and executes.

Garbage Collection (GC) is responsible for reclaiming heap memory occupied by unreachable objects. Object liveness is determined by reachability analysis using algorithms such as reference counting and root searching (GC Roots). Common GC algorithms include Mark‑Sweep, Copying, and Generational Collecting, each with trade‑offs in efficiency, fragmentation, and pause times. Parallel and concurrent collectors aim to reduce application pause times, while minor (young‑gen) and major (old‑gen) collections differ in speed and impact.

GC collector types are categorized as NEW (e.g., Serial, ParNew, Parallel Scavenge) and OLD/Tenured (e.g., Serial Old, Parallel Old, CMS). Modern collectors like G1 divide the heap into regions and prioritize reclaiming the most valuable regions.

Class‑loader Subsystem locates and loads binary class files, verifies them, allocates memory for static variables, and resolves symbolic references. It includes the bootstrap classloader, extension classloader, application classloader, and user‑defined classloaders (e.g., class MyClassLoader extends ClassLoader). Loading follows the parent‑delegation model: a request is passed up the hierarchy (application → extension → bootstrap) before the child attempts to load the class.

Execution Engine executes the bytecode instructions. It consists of the Interpreter, which reads and executes bytecode directly, and the Just‑In‑Time (JIT) compiler, which translates bytecode to native machine code at runtime for faster execution.

Runtime Data Areas include:

Heap – shared memory for all object instances, the primary GC target.

Method Area (or Permanent Generation) – stores class metadata, static variables, and compiled code.

Program Counter (PC) Register – per‑thread pointer to the next bytecode instruction.

JVM Stack – per‑thread stack for primitive values, object references, and call frames.

Native Method Stack – supports execution of native (non‑Java) methods.

GC Command‑Line Options (selected examples):

Command line

Young‑gen GC

Old‑gen GC -XX:+UseSerialGC Serial (young)

SerialOld (old) -XX:+UseParNewGC ParNew (parallel young)

default -XX:+UseParallelGC Parallel (young)

default -XX:+UseParallelOldGC default

Parallel Old -XX:+UseConcMarkSweepGC default

CMS (concurrent) -XX:+UseG1GC G1

G1

Default collectors by Java version are Parallel GC for Java 7 and 8, and G1 GC for Java 9 and later.

The article was compiled by the author based on books and blogs, aiming to provide a clear understanding of JVM internals.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaJVMMemory ManagementRuntimeGarbage Collectionclassloader
Big Data Technology & Architecture
Written by

Big Data Technology & Architecture

Wang Zhiwu, a big data expert, dedicated to sharing big data technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.