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

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

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

  • <legend id='gn2Mt'><style id='gn2Mt'><dir id='gn2Mt'><q id='gn2Mt'></q></dir></style></legend>
        <tfoot id='gn2Mt'></tfoot>

        如何在java中销毁一个对象?

        时间:2023-07-12
      1. <small id='eGIk9'></small><noframes id='eGIk9'>

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

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

                    <tbody id='eGIk9'></tbody>

                  <legend id='eGIk9'><style id='eGIk9'><dir id='eGIk9'><q id='eGIk9'></q></dir></style></legend>
                1. 本文介绍了如何在java中销毁一个对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在一次采访中遇到了这个问题,有以下选择:

                  I encountered this question in an interview with following options:

                  如何在java中销毁一个对象?

                  How to destroy an object in java?

                  a. System.gc();  
                  b. Runtime.getRuntime.gc();  
                  c. object.delete();  
                  d. object.finalize();  
                  e. Java performs gc by itself, no need to do it manually.
                  

                  1. 答案应该是e?

                  1. The answer should be e?

                  如果没有 e 怎么办?然后 ?显然 c 不是答案.a 和 b 将为整个应用程序执行 gc(问题需要一个对象).我认为它是 d 因为 finalize() 在 gc 之前被调用(但是在 finalize gc 被调用之后是否有必要?)或者我错了?e 必须在场才能回答这个问题?

                  what if e was not there? then ? clearly c is not the answer. a and b will do gc for the whole application(question requires for one object). I think it is d because finalize() is called just prior to gc(but is it necessary that after finalize gc is invoked ?) or I am wrong ? e must be there to answer this question ?

                  推荐答案

                  答案 E 是正确答案.如果 E 不存在,你很快就会耗尽内存(或)没有正确答案.

                  Answer E is correct answer. If E is not there, you will soon run out of memory (or) No correct answer.

                  对象应该是不可访问的,才有资格进行 GC.JVM 会进行多次扫描并将对象从一代移动到另一代,以确定 GC 的资格,并在对象不可达时释放内存.

                  Object should be unreachable to be eligible for GC. JVM will do multiple scans and moving objects from one generation to another generation to determine the eligibility of GC and frees the memory when the objects are not reachable.

                  这篇关于如何在java中销毁一个对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从命令行检查正在运行的 JVM 的堆使用情况? 下一篇:为高响应服务器应用程序调整 JVM (GC)

                  相关文章

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

                      <tfoot id='36fdv'></tfoot>