• <legend id='Dr8wd'><style id='Dr8wd'><dir id='Dr8wd'><q id='Dr8wd'></q></dir></style></legend>
  • <small id='Dr8wd'></small><noframes id='Dr8wd'>

      <bdo id='Dr8wd'></bdo><ul id='Dr8wd'></ul>

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

        显式调用 System.gc()?

        Calling System.gc( ) explicitly?(显式调用 System.gc()?)
          <tbody id='shOGL'></tbody>

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

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

                <bdo id='shOGL'></bdo><ul id='shOGL'></ul>

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

                  本文介绍了显式调用 System.gc()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  据说java中不能强制垃圾回收进程.
                  毕竟,它是一个守护线程.

                  It is said that we cannot force the garbage collection process in java.
                  It's after all, a daemon thread.

                  但有时,为什么我们显式调用 System.gc( ); 函数?
                  值得打电话吗?任何优点和缺点?
                  如果在许多情况下都没有用,为什么 Java 不弃用此方法?

                  But still sometimes, why we call the System.gc( ); function explicitly ?
                  Is it worth calling it ? Any Pro's and Con's ?
                  If not useful in many situations, why this method is not deprecated from Java ?

                  PS : 举例说明会很有用

                  PS : Explanation with an example will be useful

                  推荐答案

                  在我看来,将 System.gc() 方法看作是对应该运行垃圾收集的 VM.话虽如此,就像人们认为他们正在执行的大部分优化"一样,通常最好让系统自行处理.系统在不断发展,等等.还有一些情况,开发人员实际上可能知道得更好,并且它的用例可能与为什么某些代码仍然用汇编编写非常相似(大多数时候,编译器更好,但在少数情况下——或者在少数开发人员的情况下——人类实际上可以编写更高效的代码).

                  The best way, in my opinion, to think of the System.gc() method is as a "hint" to the VM that garbage collection should run. That said, much like a large percentage of "optimizations" people think they are performing, it's usually best to just let the system take care of things on its own. Systems are evolving etc, etc, etc. There are still some instances where the developer may actually know better and the use case for it is probably very similar to why some code is still written in assembly (most of the time, the compiler is better, but in a few instances -- or with a few developers -- humans can actually write more efficient code).

                  我在过去看到的一个用于证明其存在的示例是,如果分配了大量对象,并且作为开发人员的您知道它们将不再被使用的那一刻.在这种情况下,您可能比 GC 拥有更多关于内存利用率的信息(或至少在它意识到之前),并且由于回收的内存量很大,因此建议它运行是有意义的.

                  One example I've seen used in the past to justify its existence is in the event that a large number of objects were allocated and you as the developer know the instant they are no longer going to be used. In that case, you may have more information about the memory utilization than the GC does (or at least, before it realizes it) and, since the amount of memory reclaimed will be significant, it makes sense to suggest that it runs.

                  这篇关于显式调用 System.gc()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

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

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

                        1. <small id='JBN4a'></small><noframes id='JBN4a'>

                            <tbody id='JBN4a'></tbody>