Sign in

Java virtual machine - questions about memory set

Antonino edited in Wed, 25 Jan 2023

Look at the traditional garbage collector (non-g1) in "deep understanding of Java virtual machine" which uses the memory set to handle the root node enumeration problem when cross generation reference. It's said in it

In the new generation, a global data structure called memory set is established. This structure divides the old generation into several small blocks and identifies which memory block of the old generation will have cross generation reference. When minor GC occurs, only the old age objects in small memory containing cross generation references will be added to GC roots to avoid the whole old age from being added to GC roots.

There's a question here. There are also new generation citations, such as cross generation citations from the old generation. Don't we need to build a memory set in the old generation? Otherwise, the whole new generation will have to be added to GC roots.

It is also said in the book that only the CMS garbage collector can recycle the old age independently. Other garbage collectors know when they recycle the new generation. Do you have any references from the new generation to the old age?

Without a memory set, how does CMS deal with cross generational references when it recycles the old data alone?

1 Replies
commented on Wed, 25 Jan 2023

Except that CMS can recycle the old generation separately, other old generation collectors do full GC, that is, GC of the whole heap

CMS will scan the new generation when recycling the old generation, but it does not collect the dead objects in the new generation