37

XX:MaxDirectMemorySizeのデフォルト値は何ですか?

4

3 に答える 3

44

からsun.misc.VM、それRuntime.getRuntime.maxMemory()は、で構成されているものです-Xmx。例:構成せに構成する場合、「デフォルト」も5 Gbになり、アプリのヒープ+ダイレクトメモリの合計使用量は5 + 5 =10Gbに増加する可能性があります。-XX:MaxDirectMemorySize-Xmx5gMaxDirectMemorySize

于 2017-09-07T19:05:43.217 に答える
20

http://www.docjar.com/html/api/sun/misc/VM.java.htmlから

そうですか:

 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;

したがって、デフォルトで64メガになっているように見えます。

于 2010-09-22T21:56:43.280 に答える
8

JDK8の場合:

64MBは最初は任意に設定されます...

(From:https ://github.com/frohoff/jdk8u-dev-jdk/blob/master/src/share/classes/sun/misc/VM.java#L186 )

    // 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;

...しかし、directMemoryはmaxMemory()に設定されます〜=ここではヒープサイズ(maxDirectMemorySize-Parameterが設定されていない場合):

https://github.com/frohoff/jdk8u-dev-jdk/blob/master/src/share/classes/sun/misc/VM.java#L286から)

  // 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;
      }
  }

テストは、この主張「test.java.nio.Buffer.LimitDirectMemory.java」をサポートしているようです。

https://github.com/frohoff/jdk8u-dev-jdk/blob/da0da73ab82ed714dc5be94acd2f0d00fbdfe2e9/test/java/nio/Buffer/LimitDirectMemory.java#L74から)

 if (size.equals("DEFAULT"))
            return (int)Runtime.getRuntime().maxMemory();
于 2019-01-30T19:00:17.087 に答える