Posts

Showing posts from January, 2026

Execution Engine

Execution Engine Phase  Once .class files are loaded, linked, and initialized, the JVM moves into execution phase. Execution Engine is the place Where Code actually Runs It contains:- Interpreter JIT (Just in Time) Garbage Collector 1. Interpreter    Interpreter reads bytecode one instruction at a time and executes it immediately. Interpreter works like: Read instruction 1 → execute Read instruction 2 → execute Read instruction 3 → execute Very fast startup, No waiting for compilation and Slower for long-running programs 2. JIT Compiler (Just-in-time) Detects hot methods(frequently executed) Converts bytecode - native machine code Stores optimized code for reuse It results, Much faster execution and JVM becomes faster over time What are “Hot Methods”? Methods inside loops Frequently called methods Business logic methods in servers Why JIT makes JVM faster Once compiled: JVM does not interpret again CPU runs native machine code directly Execution becomes much faster When y...

Runtime Memory Area

Image
Runtime Data Areas When JVM starts, it creates runtime memory areas: These are divided into two categories: Thread Shared (Not Thread Safe) Heap  Method Area  (Metaspace) Thread Private (Thread Safe) Stack PC Register Native Method Stack Heap (Shared) When we creates an object then it stores in Heap either it creates with new keyword or clone or reflection etc.  But important thing is it all stores in Heap seperately. Heap Memory is shared by all Threads It is managed by Garbage Collector It is the Largest Memory Area Heap Memory divides into two part: Young Generation Eden S0 S1 Old Generation If Heap Fails : java.lang.OutOfMemoryError   Object stored in Young Generation, when if it is retain for long period then it moves to Old Generation. Method Area (Metaspace) In this memory area JVM stores Class Metadata, Method Metadata, Variable Information, Constructor, Runtime Constant Pool, Static Variable etc  After Java 8+ Method Area implemented as Metaspace Differ...

JVM-ClassLoader

Image
Class Loader Subsystem ensures that classes are loaded safely, lazily, and hierarchically, enabling Java’s security, modularity, and runtime flexibility. Virtual Machine is a software simulation of a machine which can perform an operations like a physical machine. Hardware Based/System Based Virtual Machine VMWare VirtualBox Cloud Computing (AWS EC2, Azure VM) Application Based/Process Based Vitual Machine   JVM for Java .NET CLR for Dot Net PVM for Perl Why we need JVM JVM is responsible for making Java program Platform Independent, We write a Java Code (.java) --then--> compiler (javac) --compile it and create --> Byte Code (.class) --then--> Java Interpreter convert into machine code How JAVA Runs the Application JVM Architecture Think of JVM as 4 major pillars : 1️⃣ Class Loader Subsystem 2️⃣ Runtime Data Areas (Memory) 3️⃣ Execution Engine 4️⃣ Native Interface & Libraries Class Loader Subsystem The Class Loader Subsystem perform three part: Loading ...

From Power ON → Firmware → OS Kernel → Process Creation → JVM → Bytecode Execution, every layer matters when you’re designing:

Image
 I’ve created this visual to help junior developers understand the full journey — from hardware to Java execution. Break down it into 4 clear stages: Stage 1: System Boot A computer contains: CPU → the "thinking" unit RAM → temporary workspace for running programs Hard Disk / SSD → permanent storage When the computer is off: RAM is empty CPU has no instructions OS resides on the disk, not in memory The computer doesn’t yet know where the OS is. Step 1 – Power ON: Firmware Starts Firmware: a small permanent program on the motherboard (examples: BIOS/UEFI) Why is it needed? CPU doesn’t know where OS is CPU doesn’t know how to use RAM or disk Firmware acts as the CPU’s first teacher What firmware does: Takes control of CPU Performs hardware checks (RAM, CPU, Disk) → POST (Power-On Self Test) Finds a bootable device → locates the OS Step 2 – Bootloader Loads Firmware loads the bootloader from the disk: Windows → Windows Boot Manager Linux → GRUB Bootloader loads the OS kernel in...