The Old Generation in Java is a part of the heap that stores long-lived objects that have survived multiple garbage collection cycles. Objects are initially allocated in the Young Generation and, after surviving several Minor GCs, are promoted to the Old Generation where they remain until a Major GC removes them. The Old Generation is larger than the Young Generation and is collected using a more expensive GC algorithm, posing a risk of OutOfMemoryError if full.
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 ratings0% found this document useful (0 votes)
0 views2 pages
In Java
The Old Generation in Java is a part of the heap that stores long-lived objects that have survived multiple garbage collection cycles. Objects are initially allocated in the Young Generation and, after surviving several Minor GCs, are promoted to the Old Generation where they remain until a Major GC removes them. The Old Generation is larger than the Young Generation and is collected using a more expensive GC algorithm, posing a risk of OutOfMemoryError if full.
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/ 2
In depth Old gen in gc in Java
- by utk
What Is the Old Generation?
The Old Generation (Tenured Generation) is a region of the Java heap that stores objects that have survived multiple garbage collection cycles in the Young Generation.
Think of it as the “retirement home” for objects that the JVM
1. New objects are allocated in Eden (Young Gen). 2. If they survive a few Minor GCs, they are moved to Survivor spaces. 3. After surviving a set number of GCs (-XX:MaxTenuringThreshold, default: 15), they are promoted to the Old Generation. 4. Once in Old Gen, they stay there until a Major (or Full) GC removes them. 🔥 Characteristics of Old Gen Feature Details Long-lived objects (e.g. cached data, session Contains objects) Size Larger than Young Gen Collected by Major GC or Full GC GC Algorithm Mark-Sweep-Compact (or Region-based in G1) Performance More expensive to collect, longer pause times Impact Risk If full → OutOfMemoryError: Java heap space
🔍 Example: Old Gen in Action
Suppose you have this:
java CopyEdit List<String> cache = new ArrayList<>();
for (int i = 0; i < 1000000; i++) {
cache.add("Data-" + i); }
If cache is kept as a global variable (or static field), those strings
may survive enough Minor GCs to be promoted to Old Gen.