Skip to content

-XX:MaxDirectMemorySize

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

Syntax

-XX:MaxDirectMemorySize=<size>
Setting Value Default
<size> [1[k|K|m|M|g|G] or greater] Depends on maximum heap size

The value you choose is the limit on memory that can be reserved for all Direct Byte Buffers. If a value is set for this option, the sum of all Direct Byte Buffer sizes cannot exceed the limit. After the limit is reached, a new Direct Byte Buffer can be allocated only when enough old buffers are freed to provide enough space to allocate the new buffer.

Start of content that applies to Java 8 By default, the amount of native memory used for Direct Byte Buffers is limited to 87.5% of the maximum heap size.

Start of content that applies to Java 11 plus By default, the amount of native memory used for Direct Byte Buffers is limited to the maximum heap size.