• <tfoot id='yMMO9'></tfoot>

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

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

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

      1. <legend id='yMMO9'><style id='yMMO9'><dir id='yMMO9'><q id='yMMO9'></q></dir></style></legend>

        你如何从 Shell 强制垃圾收集?

        How do you Force Garbage Collection from the Shell?(你如何从 Shell 强制垃圾收集?)

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

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

                  <tbody id='hzbCJ'></tbody>
                  本文介绍了你如何从 Shell 强制垃圾收集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我在一个远程盒子上查看一个带有 jmap 的堆,我想强制对其进行垃圾收集.在不弹出 jvisualvm 或 jconsole 和朋友的情况下如何做到这一点?

                  So I am looking at a heap with jmap on a remote box and I want to force garbage collection on it. How do you do this without popping into jvisualvm or jconsole and friends?

                  我知道您不应该进行强制垃圾回收的做法——您应该弄清楚堆变大/增长的原因.

                  I know you shouldn't be in the practice of forcing garbage collection -- you should just figure out why the heap is big/growing.

                  我也意识到 System.GC() 实际上并不强制进行垃圾回收——它只是告诉 GC 你希望它发生.

                  I also realize the System.GC() doesn't actually force garbage collection -- it just tells the GC that you'd like it to occur.

                  话虽如此,有没有办法轻松做到这一点?我缺少一些命令行应用程序?

                  Having said that is there a way to do this easily? Some command line app I'm missing?

                  推荐答案

                  你可以通过免费的 jmxterm 程序.

                  You can do this via the free jmxterm program.

                  像这样启动它:

                  java -jar jmxterm-1.0-alpha-4-uber.jar
                  

                  从那里,您可以连接到主机并触发 GC:

                  From there, you can connect to a host and trigger GC:

                  $>open host:jmxport
                  #Connection to host:jmxport is opened
                  $>bean java.lang:type=Memory
                  #bean is set to java.lang:type=Memory
                  $>run gc
                  #calling operation gc of mbean java.lang:type=Memory
                  #operation returns: 
                  null
                  $>quit
                  #bye
                  

                  查看 jmxterm 网站上的文档,了解有关将其嵌入 bash/perl/ruby/其他脚本的信息.我在 Python 中使用了 popen2 或在 Perl 中使用了 open3.

                  Look at the docs on the jmxterm web site for information about embedding this in bash/perl/ruby/other scripts. I've used popen2 in Python or open3 in Perl to do this.

                  更新:这是一个使用 jmxterm 的单行:

                  UPDATE: here's a one-liner using jmxterm:

                  echo run -b java.lang:type=Memory gc | java -jar jmxterm-1.0-alpha-4-uber.jar -n -l host:port
                  

                  这篇关于你如何从 Shell 强制垃圾收集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

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

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

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

                      • <tfoot id='yYY9Y'></tfoot>