Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default for XX:MaxDirectMemorySize

What is the default value for XX:MaxDirectMemorySize?

like image 540
Timur Fanshteyn Avatar asked Sep 22 '10 21:09

Timur Fanshteyn


People also ask

What is XX MaxDirectMemorySize?

This Oracle HotSpot option sets a limit on the amount of memory that can be reserved for all Direct Byte Buffers.

What is Max direct memory?

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.

What is Offheap memory in Java?

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.

What is Java direct memory?

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.


2 Answers

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.

like image 181
leventov Avatar answered Oct 05 '22 13:10

leventov


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.

like image 32
John Gardner Avatar answered Oct 05 '22 13:10

John Gardner