IDRASAcademic OS
Unit 1: JVM Internal Architecture & Memory Management 35 mins study timeFOUNDATION

JVM Runtime Architecture, Heap Generations & Garbage Collection (G1/ZGC)

Class loading stages (Loading, Linking, Initialization), Method Area, Heap space, JVM Stack frames, and generational garbage collection.

Verified: Faculty Peer Review Board

Learning Objectives

    Essential Prerequisites

      Layer 1: Intuition & Why It Matters

      The Core Mental Model

      “Java ka sabse bada revolutionary feature hai: "Write Once, Run Anywhere!" C++ me agar aapne code likha to Linux ke liye alag compile karna padega, Windows ke liye alag. Lekin Java me code compile hokar 'Bytecode (.class)' banta hai. JVM (Java Virtual Machine) ek 'Universal Translator' ki tarah hai: Aap Bytecode lekar chahe Linux server par jao, Mac par ya Android phone par, agar wahan JVM installed hai to code bina kisi badlav ke chalega! Garbage Collector (Automatic Safai): Aapko C ki tarah 'free()' karne ki tension nahi hoti. JVM ka Garbage Collector un objects ko dhoondh kar clean karta hai jinko ab koi use nahi kar raha.”

      Why This Exists

      Banking platforms, Apache Kafka, Elasticsearch, aur Android apps JVM par run karte hain.

      Beginner Foundation

      Java ka sabse bada revolutionary feature hai: "Write Once, Run Anywhere!" C++ me agar aapne code likha to Linux ke liye alag compile karna padega, Windows ke liye alag. Lekin Java me code compile hokar 'Bytecode (.class)' banta hai. JVM (Java Virtual Machine) ek 'Universal Translator' ki tarah hai: Aap Bytecode lekar chahe Linux server par jao, Ma...

      Micro Concepts Decomposition

      MICRO CONCEPT 1Canonical Object

      Write Once, Run Anywhere (WORA) Bytecode

      Java source (.java) compiles to platform-independent bytecode (.class). JVM interprets or JIT-compiles bytecode to host machine instructions.

      Key Takeaway: JVM abstraction decouples enterprise software from underlying Linux/Windows/ARM OS differences.
      MICRO CONCEPT 2Canonical Object

      Generational Heap & Garbage Collection

      Young Generation (Eden + Survivor S0/S1) collects short-lived objects via Minor GC; Old/Tenured Generation collects long-lived objects via Major GC.

      Key Takeaway: G1 and ZGC garbage collectors minimize Stop-the-World pauses, preserving sub-millisecond API response latencies.
      Layer 3 & 4: Formal Specification & Mechanism

      Hardware State Machine Architecture

      JVM Architecture consists of 3 primary subsystems: 1. ClassLoader Subsystem: Loading (Bootstrap, Extension/Platform, Application), Linking (Verify, Prepare, Resolve), and Initialization. 2. Runtime Data Areas: - Method Area / Metaspace: Class metadata, runtime constant pool. - Heap: Shared memory storing object instances. - JVM Stacks: Thread-private stack frames containing local variables and operand stack. - PC Registers: Current bytecode instruction address per thread. - Native Method Stacks. 3. Execution Engine: Bytecode Interpreter, JIT Compiler, Garbage Collector.
      1. Javac compiles .java to .class bytecode. 2. ClassLoader reads bytecode and verifies safety. 3. New operator allocates object in Eden space. 4. When Eden fills, Minor GC copies surviving objects to Survivor space. 5. Objects surviving multiple GC cycles are promoted to Old/Tenured space.
      Layer 7: Interactive Laboratory

      Interactive Simulator

      JAVA • LABJava ClassLoader Delegation & Bytecode Verification Lab
      Launch Fullscreen Lab
      JAVA • JVM RUNTIMEGenerational Heap & Garbage Collection

      JVM Generational Memory & Garbage Collection Laboratory

      Young Generation (Eden + Survivor S0/S1 Spaces)Short-lived Objects
      Eden Space2 objects
      UserDto12MB | age:0
      OrderRequest24MB | age:0
      Survivor (From / To S0, S1)1 objects
      AppConfigage:2 (threshold: 3)
      Old Generation (Tenured Space)Long-lived Objects • Promoted when age ≥ 3
      DatabaseConnectionPool64MB | Promoted (Age 8)
      JVM GC Log Event
      JVM initialized with -Xms256m -Xmx1024m.
      Weak Generational Hypothesis:

      Most objects in Java die shortly after allocation (high churn rate). By segregating the heap into Young Generation (Eden + Survivor) and Old Generation (Tenured), the JVM can run blazing-fast Minor GC pauses that scavenge Eden and promote survivors, avoiding expensive Stop-the-World Major GCs on the entire heap!

      Layer 5: Step-by-Step Worked Numerical Example

      End-to-End Execution Trace

      Object Promotion: Object created in Eden (age=0). Survived Minor GC -> moved to S0 (age=1). Next GC -> moved to S1 (age=2). When age reaches TenuringThreshold (default 15), promoted to Old Generation.
      Layer 6: Active Runtime CodeLab

      Step-by-Step Code Execution (JAVA)

      SQL Studio
      Font
      main.javaGlacier Light
      Ln 1 • Java 21
      1
      2
      3
      4
      5
      6
      7
      8
      9
      284 chars • 9 lines • Ln 1UTF-8 • 4 Spaces
      Interactive Terminal Shell

      Sandbox Terminal Ready

      Click Run Code or press Ctrl+Enter to compile and execute.

      ⚡ AURXON Bitstream Runtime v4.8IDRAS Academic Virtual Node
      Layer 8: Practice & Knowledge Verification

      Active Assessment Quiz

      No Practice Questions Configured

      Questions for this topic are currently undergoing faculty review.

      Academic Evaluation Preparation

      Viva Examination & University Scoring Strategy

      Standard Viva Examination Questions

      How to Write High-Scoring University Exam Answers

      Draw the complete JVM Architecture diagram with labels, explain all 5 Runtime Data Areas, trace generational garbage collection, and compare G1GC with ZGC.