1. <tfoot id='bGCik'></tfoot>

      • <bdo id='bGCik'></bdo><ul id='bGCik'></ul>
    1. <legend id='bGCik'><style id='bGCik'><dir id='bGCik'><q id='bGCik'></q></dir></style></legend>

    2. <small id='bGCik'></small><noframes id='bGCik'>

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

      在运行时设置 JVM 堆大小

      Setting JVM heap size at runtime(在运行时设置 JVM 堆大小)

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

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

                本文介绍了在运行时设置 JVM 堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有没有办法从正在运行的 Java 程序中设置堆大小?

                Is there a way to set heap size from a running Java program?

                推荐答案

                没有.

                对于堆要求非常多变的应用,您可以使用 -Xmx 将最大堆大小设置得非常高,并调整 -XX:MaxHeapFreeRatio-XX:MinHeapFreeRatio 以便应用程序在堆收缩时不会挂起大量内存(它使用默认设置执行此操作).

                What you can do with an app that has very variable heap requirements is to set your max heap size very high with -Xmx and tune -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio so that the app will not hang on to a lot of memory when the heap shrinks (it does that with default settings).

                但请注意,当应用实际使用的内存变化剧烈且迅速时,这可能会导致性能问题 - 在这种情况下,您最好将其挂在所有内存上,而不是仅将其返回给操作系统一秒钟后再次申领.您可能还想摆弄 GC 选项 以确保 GC不会留下太多无人认领的对象,当堆有很大的增长空间时,它往往会这样做,这会破坏希望堆大小适应应用程序需求的目标.

                But note that this may cause performance problems when the memory actually used by the app varies both strongly and quickly - in that case you're better off having it hang on to all the memory rather than give it back to the OS only to claim it again a second later. You might also want to fiddle with the GC options to ensure that the GC doesn't leave too much unclaimed objects lying around, which it tends to do when there's a lot of room for the heap to grow, and which would defeat the goal of wanting the heap size to adjust to the app's needs.

                这篇关于在运行时设置 JVM 堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                Why a sawtooth shaped graph?(为什么是锯齿形图形?)

              • <tfoot id='iTKZZ'></tfoot>
                  <bdo id='iTKZZ'></bdo><ul id='iTKZZ'></ul>

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

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

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