简体   繁体   English

G1 GC 中如何管理栈根

[英]How roots from stack are managed in G1 GC

How does Java manage Root objects from the stack in G1 garbage collector? Java在G1垃圾回收器中如何从栈中管理Root对象? 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?它是否在垃圾收集(年轻阶段或混合阶段)时遍历所有 mutator 线程的堆栈,或者是否有一些其他类似记忆集的数据结构(用于保留代际指针的引用)以节省时间? Is there any documentation of the same.是否有任何相同的文件。

Thread stacks are always scanned, not only in G1 ;线程堆栈总是被扫描,不仅在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.但是 afaik 在 JVM 上实现的所有其他垃圾收集器中都是如此GC必须从一些已知的根开始,以便找出什么是活的,什么不是。 In case of any java's GC, these roots are made from various pieces, among others: thread stacks.对于任何 Java 的 GC,这些根由各种部分组成,其中包括:线程堆栈。

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.由于安全点轮询或线程数, STW阶段可能会变大。 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).这是一个快速的过程(使用Shenandoah 2.0 ,我看到最多15 ms的暂停)。

remembered sets fulfill a somehow different role . remembered sets扮演着不同的角色

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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