JVM Components#

1. Class Loader#
JVM’s Class Loader loads *.class files (bytecode files converted by javac) into Runtime Data Areas to run the program.
Class Loader loading occurs at runtime, when a class is first accessed. This enables Lazy Loading Singleton implementation.
- Class Loading is Thread-safe.
2. Execution Engine#
Executes the bytecode loaded into Runtime Data Areas by the Class Loader. It converts bytecode to machine code and executes it instruction by instruction, composed of 1-byte OpCode and operands.
Key Components#
- Interpreter
- Compiler (Just-in-Time)
3. Garbage Collector#
Responsible for removing unreferenced objects in the Heap area.
Before Java, programmers managed all program memory. In Java, the JVM manages program memory through a process called garbage collection.
4. Runtime Data Areas#
JVM’s memory area allocated from the OS. It holds data needed to run Java applications.
Runtime Data Areas are divided into 5 areas as follows.
Shared Areas
- Method and Heap areas are shared by all Threads
Thread-specific Areas
- Stack, PC Register, Native Method areas exist per Thread

(1) Method Area#
Created when the JVM starts, it stores runtime constant pools, field and method code, static variables, method bytecode, etc. for each class and interface read by the JVM.
PermSize (Permanent Generation size) JVM option.1-1 Type Information#
- Whether it’s an Interface
- Type name including package name
- Type access modifiers
- Associated Interface list
1-2 Runtime Constant Pool#
- Stores all references to Type, Field, and Method
- JVM finds and references memory addresses through the Runtime Constant Pool
1-3 Field Information#
- Field type
- Field access modifiers
1-4 Method Information#
- Stores metadata for all Methods including Constructors
- Stores Method name, parameter count and type, return type, access modifiers, bytecode, local variable section size, etc.
1-5 Class Variable#
- Stores variables declared with the
statickeyword - Actual instances of non-primitive static variables are stored in Heap memory
(2) Heap Area#
Space for storing objects created with the new operator.
(3) Stack Area#
Stored as separate Frames per Thread, with the following elements stored.
3-1 Local Variable Area#
- Stores temporary data occurring during Method execution, such as local variables, parameters, and method call addresses
- Stored in 4-byte units: 4-byte primitives like
int,floatoccupy 1 cell; 8-byte primitives likedoubleoccupy 2 cells boolgenerally occupies 1 cell
3-2 Operand Stack#
- The Method’s workspace
- Indicates which commands to execute with which operands
3-3 Frame Data#
- Includes Constant Pool Resolution, Method Return, Exception Dispatch, etc.
- Also holds referenced Exception tables
- When an Exception occurs, JVM references this table to determine how to handle the Exception
(4) PC Register#
Created when a Thread starts, one exists per thread.
Holds the address of the currently executing portion of the Thread, recording which part should be executed with which instruction.
(5) Native Method Stack#
Area for executing programs written in actual executable machine code rather than bytecode generated from Java program compilation.
- Space for code written in languages other than Java
- Converted to bytecode and stored through the Java Native Interface
- Area where the kernel grabs the stack and independently executes the program, like a general program
JVM Execution Order#
Memory Allocation
- When a program runs, JVM receives memory needed to execute the program from the OS
- JVM divides this memory into multiple areas for use
Compilation
- Java Compiler (
javac) compiles*.javafiles and converts them to*.classJava bytecode
- Java Compiler (
Class Loading
- Compiled
*.classfiles are loaded into JVM memory through the Class Loader
- Compiled
Bytecode Interpretation
- Loaded
*.classfiles are interpreted into machine code through the Execution Engine
- Loaded
Execution and Management
- Interpreted bytecode is placed in memory areas and actually executed
- During execution, JVM performs memory management tasks such as thread synchronization and garbage collector as needed



