From the books you'll know that when searching for unreachable objects, GC doesn't analyze all objects in a row. To optimize the operation, each of the objects belongs to a certain generation. It is believed that the longer an object is in memory, the greater the probability that it will remain there. For example, an object containing Main in C# will remain in memory until the end of the application. On the other hand, objects that have been placed on the heap recently (for example, objects in a method) are likely to become unreachable soon. Based on the above, each object in the heap belongs to one of the following generations:
Generation zero is the youngest generation that contains recently placed objects, for example, a temporary object. Garbage collection most often occurs in this generation.
Generation one is an object that has survived one garbage collection process. It is a buffer between short-lived and long-lived objects.
Generation two is an object that has survived more than one garbage collector run.
The garbage collector is usually called automatically, but it can also be called programmatically. You can also specify the generation up to which the GC should be started.
Here are some PDF books on garbage collection:
Java GC Tutorials - Herong's Tutorial Examples
2019 by Herong Yang

Download PDF
Professional C#
2004 by Simon Robinson

Download PDF
The Compiler Design Handbook: Optimizations and Machine Code Generation
2018 by Y.N. Srikant, Priti Shankar

Download PDF
See also: Top 10 eBook Organizers
How to download PDF:
1. Install Gooreader
2. Enter Book ID to the search box and press Enter
3. Click "Download Book" icon and select PDF*
* - note that for yellow books only preview pages are downloaded


