I found the "Java Garbage Collection Basic“ tutorial on Oracle's website:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
including the following content:
The Generational Garbage Collection Process Now that you understand why the heap is separted into different generations, it is time to look at how exactly these spaces interact. The pictures that follow walks through the object allocation and aging process in the JVM.
First, any new objects are allocated to the eden space. Both survivor spaces start out empty.

But in this image, the "from" survivor space is not empty, it has two objects, one is 1 aged and the other is 3 aged. Is this an error?
No, this is not an error.
The image is just not showing the situation before the very first minor garbage collection. Bullet 2 and 3 in your link state that:
- When the eden space fills up, a minor garbage collection is triggered.
- Referenced objects are moved to the first survivor space. Unreferenced objects are deleted when the eden space is cleared.
Hence, referenced objects in the eden space move to the survivor space during a minor garbage collection and each subsequent minor GC increments the age of a surviving object. So according to the image, there must have been at least 3 minor GCs before the new object was allocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With