简体   繁体   中英

How roots from stack are managed in G1 GC

How does Java manage Root objects from the stack in G1 garbage collector? Does it traverse the stacks of all the mutator threads while garbage collecting(young or mixed phase) or is there some other data structures similar remember sets (used to keep the reference of intergenerational pointers) to save time? Is there any documentation of the same.

Thread stacks are always scanned, not only in G1 ; but afaik in every other garbage collector implemented on the JVM. A GC has to start with some known roots in order to find out what is alive and what not. In case of any java's GC, these roots are made from various pieces, among others: thread stacks.

At every cycle, these are scanned; after all they will be changed and will be different potentially at each cycle. The painful part is that until this is implemented , this is a stop-the-world phase. And STW phases can get big due to safe point polling or number of threads. In real life scenarios (at least the ones that I have been involved with), this is not a concern; it's a fast process (with Shenandoah 2.0 , I have seen max of 15 ms pause).

remembered sets fulfill a somehow different role .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM