<legend id='vFJWI'><style id='vFJWI'><dir id='vFJWI'><q id='vFJWI'></q></dir></style></legend>
        <tfoot id='vFJWI'></tfoot>

        <i id='vFJWI'><tr id='vFJWI'><dt id='vFJWI'><q id='vFJWI'><span id='vFJWI'><b id='vFJWI'><form id='vFJWI'><ins id='vFJWI'></ins><ul id='vFJWI'></ul><sub id='vFJWI'></sub></form><legend id='vFJWI'></legend><bdo id='vFJWI'><pre id='vFJWI'><center id='vFJWI'></center></pre></bdo></b><th id='vFJWI'></th></span></q></dt></tr></i><div id='vFJWI'><tfoot id='vFJWI'></tfoot><dl id='vFJWI'><fieldset id='vFJWI'></fieldset></dl></div>

        <small id='vFJWI'></small><noframes id='vFJWI'>

          <bdo id='vFJWI'></bdo><ul id='vFJWI'></ul>
      1. java - 垃圾收集器如何快速知道哪些对象不再引用它们?

        java - How can Garbage Collector quickly know which objects do not have references to them any more?(java - 垃圾收集器如何快速知道哪些对象不再引用它们?)
          <tbody id='yE9pt'></tbody>

        <i id='yE9pt'><tr id='yE9pt'><dt id='yE9pt'><q id='yE9pt'><span id='yE9pt'><b id='yE9pt'><form id='yE9pt'><ins id='yE9pt'></ins><ul id='yE9pt'></ul><sub id='yE9pt'></sub></form><legend id='yE9pt'></legend><bdo id='yE9pt'><pre id='yE9pt'><center id='yE9pt'></center></pre></bdo></b><th id='yE9pt'></th></span></q></dt></tr></i><div id='yE9pt'><tfoot id='yE9pt'></tfoot><dl id='yE9pt'><fieldset id='yE9pt'></fieldset></dl></div>
      2. <tfoot id='yE9pt'></tfoot>
        <legend id='yE9pt'><style id='yE9pt'><dir id='yE9pt'><q id='yE9pt'></q></dir></style></legend>

                • <bdo id='yE9pt'></bdo><ul id='yE9pt'></ul>
                • <small id='yE9pt'></small><noframes id='yE9pt'>

                  本文介绍了java - 垃圾收集器如何快速知道哪些对象不再引用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道在 Java 中,如果一个对象不再有任何对它的引用,垃圾收集器会在一段时间后回收它.

                  I understand that in Java, if an object doesn't have any references to it any more, the garbage collector will reclaim it back some time later.

                  但是垃圾收集器如何知道一个对象有没有关联的引用呢?

                  But how does the garbage collector know that an object has or has not references associated to it?

                  垃圾收集器是否使用某种 hashmap 或表?

                  Is garbage collector using some kind of hashmap or table?

                  请注意,我不是在问 gc 的工作原理.真的,我不是在问这个.

                  Please note that I am not asking how generally gc works. really, I am not asking that.

                  我要特别地询问 gc 如何高效地知道哪些对象是活动的,哪些是死的.

                  I am asking specifically that How gc knows which objects are live and which are dead, with efficiencies.

                  这就是为什么我在我的问题中说 gc 维护某种 hashmap 或集合,并不断更新对象的引用数量?

                  That's why I say in my question that is gc maintain some kind of hashmap or set, and consistently update the number of references an object has?

                  推荐答案

                  典型的现代 JVM 使用几种不同类型的垃圾收集器.

                  A typical modern JVM uses several different types of garbage collectors.

                  一种常用于已存在一段时间的对象的类型称为 Mark-and-Sweep.它基本上涉及从已知的活动"对象(所谓的垃圾收集根)开始,跟踪所有对象引用链,并将每个可达对象标记为活动".

                  One type that's often used for objects that have been around for a while is called Mark-and-Sweep. It basically involves starting from known "live" objects (the so-called garbage collection roots), following all chains of object references, and marking every reachable object as "live".

                  完成此操作后,sweep 阶段可以回收那些尚未标记为活动"的对象.

                  Once this is done, the sweep stage can reclaim those objects that haven't been marked as "live".

                  为了让这个过程正常工作,JVM 必须知道每个对象引用在内存中的位置.这是垃圾收集器精确(Java 就是这样).

                  For this process to work, the JVM has to know the location in memory of every object reference. This is a necessary condition for a garbage collector to be precise (which Java's is).

                  这篇关于java - 垃圾收集器如何快速知道哪些对象不再引用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Maven JAVA_HOME environment variable is not defined correctly, but it is(Maven JAVA_HOME 环境变量未正确定义,但它是)
                  Java System Environment Variable(Java 系统环境变量)
                  Java -classpath option(Java -classpath 选项)
                  Read environment variable in SpringBoot(在 SpringBoot 中读取环境变量)
                  Tomcat 8 - context.xml use Environment Variable in Datasource(Tomcat 8 - context.xml 在数据源中使用环境变量)
                  Issue with JAVA_HOME(JAVA_HOME 的问题)

                  <i id='n0w8J'><tr id='n0w8J'><dt id='n0w8J'><q id='n0w8J'><span id='n0w8J'><b id='n0w8J'><form id='n0w8J'><ins id='n0w8J'></ins><ul id='n0w8J'></ul><sub id='n0w8J'></sub></form><legend id='n0w8J'></legend><bdo id='n0w8J'><pre id='n0w8J'><center id='n0w8J'></center></pre></bdo></b><th id='n0w8J'></th></span></q></dt></tr></i><div id='n0w8J'><tfoot id='n0w8J'></tfoot><dl id='n0w8J'><fieldset id='n0w8J'></fieldset></dl></div>

                  1. <tfoot id='n0w8J'></tfoot>
                        • <bdo id='n0w8J'></bdo><ul id='n0w8J'></ul>
                              <tbody id='n0w8J'></tbody>
                          • <small id='n0w8J'></small><noframes id='n0w8J'>

                            <legend id='n0w8J'><style id='n0w8J'><dir id='n0w8J'><q id='n0w8J'></q></dir></style></legend>