I read about GC and I realized there is not one way that the GC works but two?
First is the normal GC:
- Detect the garbage objects using the application roots
- Gather the objects to free, in the freachable queue
- Call the finalize method of all the object in the freachable queue
- Erase all the finalized objects in the next GC round.
The second is generational GC:
- Scan the objects and detect the objects to free and erase them
- Pass the ones that survived to generation 2 (to scan them less times)
- Pass the most survived objects to generation 3.
I'm totally confused: are these two different types of GC? Or is the generational GC is like an upgrade of the first? Or is it the same?
What is the way that the .NET works?