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

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

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

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

      运行 JVM 的 GC 参数是什么?

      时间:2023-07-12

      <tfoot id='jkAmA'></tfoot>
        <bdo id='jkAmA'></bdo><ul id='jkAmA'></ul>

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

          <tbody id='jkAmA'></tbody>

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

          1. <legend id='jkAmA'><style id='jkAmA'><dir id='jkAmA'><q id='jkAmA'></q></dir></style></legend>
              • 本文介绍了运行 JVM 的 GC 参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我仍在调查我在 GC 调优方面遇到的问题(请参阅 之前的问题),涉及大量阅读和实验.

                I'm still investigating issues I have with GC tuning (see prior question), which involves lots of reading and experimentation.

                Sun Java5+ JVM 尝试根据其环境自动选择最佳 GC 策略和参数,这很棒,但我不知道如何查询正在运行的 JVM 以找出这些参数是什么.

                Sun Java5+ JVMs attempt to automatically select the optimal GC strategy and parameters based on their environment, which is great, but I can't figure out how to query the running JVM to find out what those parameters are.

                理想情况下,我想看看虚拟机自动选择的各种与 GC 相关的 -XX 选项的值.如果我有这个,我可以有一个基线来开始调整.

                Ideally, I'd like to see what values of the various GC-related -XX options are being used, as selected automatically by the VM. If I had that, I could have a baseline to begin tweaking.

                有人知道从正在运行的 VM 中恢复这些值吗?

                Anyone know to recover these values from a running VM?

                推荐答案

                查看HotSpotDiagnosticMBean

                以下示例将打印出选项的值以及该值是 DEFAULT 还是 VM_CREATION:

                The following example will print out the value of an option as well as whether the value is DEFAULT or VM_CREATION:

                import java.lang.management.ManagementFactory;
                
                import javax.management.ObjectName;
                import javax.management.openmbean.CompositeData;
                import javax.management.openmbean.CompositeDataSupport;
                
                public class HotSpotTest {
                
                    public static void main(String [] args) throws Exception {
                        printHotSpotOption("MaxHeapFreeRatio");
                        printHotSpotOption("SurvivorRatio");
                        printHotSpotOptions();
                    }
                
                    private static void printHotSpotOption(String option) throws Exception {
                        ObjectName name = new ObjectName("com.sun.management:type=HotSpotDiagnostic");
                        String operationName = "getVMOption";
                        Object [] params = new Object [] {option};
                        String [] signature = new String[] {String.class.getName()};
                        Object result = ManagementFactory.getPlatformMBeanServer().invoke(name, operationName, params, signature);
                        CompositeDataSupport data = (CompositeDataSupport) result;
                
                        System.out.println(option);
                        System.out.println("- Value: "+data.get("value"));
                        System.out.println("- Origin: "+data.get("origin"));
                    }
                
                    private static void printHotSpotOptions() throws Exception {
                        ObjectName name = new ObjectName("com.sun.management:type=HotSpotDiagnostic");
                        String attributeName = "DiagnosticOptions";
                        Object result = ManagementFactory.getPlatformMBeanServer().getAttribute(name, attributeName);
                        CompositeData [] array = (CompositeData[]) result;
                        for (CompositeData d : array) {
                            System.out.println(d.get("name"));
                            System.out.println("- Value: "+d.get("value"));
                            System.out.println("- Origin: "+d.get("origin"));
                        }
                    }
                }
                

                这篇关于运行 JVM 的 GC 参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:为什么存在WeakHashMap,却没有WeakSet? 下一篇:什么时候删除 Java 临时文件?

                相关文章

                • <bdo id='vsiDL'></bdo><ul id='vsiDL'></ul>

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

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

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