Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java XX的默认值:MaxDirectMemorySize_Java_Memory Management_Jvm_Jvm Arguments_Jvm Hotspot - Fatal编程技术网

Java XX的默认值:MaxDirectMemorySize

Java XX的默认值:MaxDirectMemorySize,java,memory-management,jvm,jvm-arguments,jvm-hotspot,Java,Memory Management,Jvm,Jvm Arguments,Jvm Hotspot,XX:MaxDirectMemorySize的默认值是什么?来自 我明白了: 163 // A user-settable upper limit on the maximum amount of allocatable direct 164 // buffer memory. This value may be changed during VM initialization if 165 // "java" is launched with "-X

XX:MaxDirectMemorySize的默认值是什么?

来自

我明白了:

 163       // A user-settable upper limit on the maximum amount of allocatable direct
 164       // buffer memory.  This value may be changed during VM initialization if
 165       // "java" is launched with "-XX:MaxDirectMemorySize=<size>".
 166       //
 167       // The initial value of this field is arbitrary; during JRE initialization
 168       // it will be reset to the value specified on the command line, if any,
 169       // otherwise to Runtime.getRuntime.maxDirectMemory().
 170       //
 171       private static long directMemory = 64 * 1024 * 1024;
163//用户可设置的最大可分配直接资源量上限
164//缓冲存储器。在VM初始化过程中,如果
165/“java”是通过“-XX:MaxDirectMemorySize=”启动的。
166       //
167//此字段的初始值是任意的;在JRE初始化期间
168//它将重置为命令行上指定的值(如果有),
169//否则为Runtime.getRuntime.maxDirectMemory()。
170       //
171私有静态长directMemory=64*1024*1024;
因此,它似乎默认为64兆欧。

从,它是,这是用
-Xmx
配置的。例如。如果不配置
-XX:MaxDirectMemorySize
并配置
-Xmx5g
,“默认”
MaxDirectMemorySize
也将是5 Gb,应用程序的总堆+直接内存使用量可能会增加到5+5=10 Gb。

对于JDK8:

64MB最初是任意设置的

(发件人:)


我记得默认值是-Xmx。这应该通过一个简单的测试来验证。直接内存用于与堆无关的其他特定事情。从我在探索中发现的情况来看,64是默认值,使用-1作为值将其设置为-Xmx。作为参考,您始终可以使用
java-XX:+PrintFlagsFinal-version
打印所有标志的默认值和当前值。添加
| grep Direct
以过滤输出以显示您要查找的内容:)这----直接与之矛盾,声称它是“无限制的”?docs.oracle.com链接指向JRockit的文档,而不是OpenJDK。注释表明,如果命令行中未指定该值,则该值取自maxDirectMemory()。这里的链接()将这里的输入错误(没有这样的方法)更正为maxMemory(),这反过来等于您在命令行上设置的-Xmx。这是不正确的答案,这个答案仍然不正确。正如代码中的注释所述,第171行上的值是任意的,稍后重置。这是因为始终设置属性“sun.nio.MaxDirectMemorySize”,即使命令行上未指定
-XX:MaxDirectMemorySize
。在6b27中,它位于hospot/src/share/vm/prims/jvm.cpp:344(将值从选项复制到属性)和hospot/src/share/vm/runtime/globals.hpp:3530(默认值为-1)。在7u40中,是jvm.cpp行349-357,在8u40中是jvm.cpp 359-367。
    // A user-settable upper limit on the maximum amount of allocatable direct
    // buffer memory.  This value may be changed during VM initialization if
    // "java" is launched with "-XX:MaxDirectMemorySize=<size>".
    //
    // The initial value of this field is arbitrary; during JRE initialization
    // it will be reset to the value specified on the command line, if any,
    // otherwise to Runtime.getRuntime().maxMemory().
    //
    private static long directMemory = 64 * 1024 * 1024;
  // Set the maximum amount of direct memory.  This value is controlled
  // by the vm option -XX:MaxDirectMemorySize=<size>.
  // The maximum amount of allocatable direct buffer memory (in bytes)
  // from the system property sun.nio.MaxDirectMemorySize set by the VM.
  // The system property will be removed.
  String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
  if (s != null) {
      if (s.equals("-1")) {
         // -XX:MaxDirectMemorySize not given, take default
          directMemory = Runtime.getRuntime().maxMemory();
      } else {
         long l = Long.parseLong(s);
          if (l > -1)
              directMemory = l;
      }
  }
 if (size.equals("DEFAULT"))
            return (int)Runtime.getRuntime().maxMemory();