Difference Between Minor GC and Major GC in Java

Java uses Generational Garbage Collection where heap memory is divided into different areas. Based on which area is cleaned, Garbage Collection is classified as Minor GC and Major GC.





🔹 Minor GC (Young Generation GC)

Minor GC occurs when the Young Generation memory becomes full.

👉 Newly created objects are stored here, and most objects die quickly.

Characteristics

  • Cleans Young Generation (Eden + Survivor spaces)

  • Happens frequently

  • Fast execution

  • Short pause time

  • Promotes long-living objects to Old Generation


🔹 Major GC (Old Generation GC)

Major GC occurs when the Old Generation memory becomes full.

👉 This area contains long-lived objects.

Characteristics

  • Cleans Old (Tenured) Generation

  • Happens less frequently

  • Slower than Minor GC

  • Longer application pause time

  • More CPU usage


🔹 Key Differences



🔹 Simple Flow

  1. Objects created → Young Generation

  2. Minor GC runs → removes unused objects

  3. Surviving objects → moved to Old Generation

  4. Old Generation fills → Major GC runs


✅ Promotional Content

To deeply understand JVM internals, Garbage Collection, memory management, and real-time Java performance concepts, join the Best Java Real Time Projects Online Training in Ameerpet.

Comments

Popular posts from this blog

What is Reflection API in Java?

Spring Boot Microservices Development

Recursion & Dynamic Programming