0% found this document useful (0 votes)
0 views3 pages

In Depth Minor GC in Java

Minor Garbage Collection (GC) in Java targets the Young Generation of the JVM heap, which includes Eden and Survivor spaces, and is characterized by its speed and frequency. It occurs when the Eden space is full or when explicit requests for garbage collection are made, involving a stop-the-world pause and a mark-and-copy algorithm to manage object allocation. The process is efficient, helping to keep memory fresh and preventing unnecessary promotion of objects to the Old Generation.

Uploaded by

splusmm24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views3 pages

In Depth Minor GC in Java

Minor Garbage Collection (GC) in Java targets the Young Generation of the JVM heap, which includes Eden and Survivor spaces, and is characterized by its speed and frequency. It occurs when the Eden space is full or when explicit requests for garbage collection are made, involving a stop-the-world pause and a mark-and-copy algorithm to manage object allocation. The process is efficient, helping to keep memory fresh and preventing unnecessary promotion of objects to the Old Generation.

Uploaded by

splusmm24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

In depth minor gc in Java

- by utk

🔥 What is Minor GC?


Minor Garbage Collection refers to GC events that only affect the Young Generation
(Eden + Survivor spaces) of the JVM heap.

It is fast, happens frequently, and is less expensive than Major GC because the Young
Gen is small and short-lived objects are easy to clean.

🔹 Young Generation Structure Recap


The Young Generation (Young Gen) is part of the heap where new objects are allocated.

It consists of:

diff
CopyEdit
+-----------+------------+------------+
| Eden | Survivor 0 | Survivor 1 |
+-----------+------------+------------+

• Eden: Where all new objects are initially created.


• Survivor Spaces (S0 & S1): Objects that survive GC move here.
• The survivor spaces alternate roles after each GC cycle.

🔹 When Does Minor GC Happen?


Minor GC is triggered when:

1. Eden fills up with new allocations.


2. There isn't enough space to allocate a new object.
3. System.gc() is called (may trigger Minor and Major GC depending on heap
pressure).

🔹 How Minor GC Works – Step by Step

✅ 1. Stop-the-World Pause

All application threads pause (briefly) during a Minor GC.

✅ 2. Mark and Copy Algorithm

• Reachable objects in Eden and the active Survivor space are identified (from GC
roots).
• These live objects are copied into the other Survivor space.
• Objects that survive multiple Minor GCs (e.g., 15 by default) are promoted to Old
Gen.

✅ 3. Eden is Cleared

Once live objects are moved, Eden is wiped clean.

text
CopyEdit
Eden → Survivor 0 → Survivor 1 → Old Gen

🔹 Minor GC Example in Log


text
CopyEdit
[GC (Allocation Failure) 1024K->128K(2048K), 0.0056789 secs]

• 1024K->128K: Heap used before and after GC.


• 0.0056 secs: GC pause time (~5 ms).
• Only Young Gen is affected.

🔹 Advantages of Minor GC
Benefit Why it Matters
Fast Eden is small, copying is quick
Frequent Keeps memory fresh; avoids Old Gen promotion
Mark-and-copy is faster than mark-sweep-
Efficient Algorithm
compact

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy