What is the default value for XX:MaxDirectMemorySize?
This Oracle HotSpot option sets a limit on the amount of memory that can be reserved for all Direct Byte Buffers.
MaxDirectMemorySize. This JVM option specifies the maximum total size of java. nio (New I/O package) direct buffer allocations. It is used with network data transfer and serialization activity. The default value for direct memory buffers depends on your version of your JVM.
Off-heap memory offloads values to a storage area that is not subject to Java GC. By taking advantage of off-heap storage, an application can reduce the amount of heap storage that is subject to GC overhead. Off-heap memory works in conjunction with the heap, it does not replace it.
The direct buffer memory is the OS' native memory, which is used by the JVM process, not in the JVM heap. It is used by Java NIO to quickly write data to network or disk; no need to copy between JVM heap and native memory.
From sun.misc.VM
, it's Runtime.getRuntime.maxMemory()
, that's what is configured with -Xmx
. E. g. if you don't configure -XX:MaxDirectMemorySize
and do configure -Xmx5g
, the "default" MaxDirectMemorySize
will also be 5 Gb, and the total heap+direct memory usage of the app may grow up to 5 + 5 = 10 Gb.
From http://www.docjar.com/html/api/sun/misc/VM.java.html
i see:
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;
so it appears to default to 64 megs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With