По умолчанию для XX: MaxDirectMemorySize

каково значение по умолчанию для XX: MaxDirectMemorySize?

2 ответов


от 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 мегабайта.


С sun.misc.VM, это Runtime.getRuntime.maxMemory(), это то, что настроено с -Xmx. Е. Г. если вы не настроить -XX:MaxDirectMemorySize и do настроить -Xmx5g, "по умолчанию" MaxDirectMemorySize также будет 5 Гб, а общая куча + прямое использование памяти приложения может вырасти до 5 + 5 = 10 Гб.