code: public static DirectBuffer allocate(long initialCapacity, long maxCapacity) {
      if (initialCapacity > maxCapacity)
        throw new IllegalArgumentException("initial capacity cannot be greater than maximum capacity");
      return new DirectBuffer(DirectBytes.allocate((int) Math.min(Memory.Util.toPow2(initialCapacity), HeapMemory.MAX_SIZE)), 0, initialCapacity, maxCapacity);
    }
docs: Allocates a new direct buffer.
  <p>
  When the buffer is constructed, {@link DirectMemoryAllocator} will be used to allocate
  {@code capacity} bytes of off-heap memory. The resulting buffer will have an initial capacity of {@code initialCapacity}
  and will be doubled up to {@code maxCapacity} as bytes are written to the buffer. The underlying {@link UnsafeDirectBytes}
  will be initialized to the next power of {@code 2}.
  
  @param initialCapacity The initial capacity of the buffer to allocate (in bytes).
  @param maxCapacity The maximum capacity of the buffer.
  @return The direct buffer.
  @throws IllegalArgumentException If {@code capacity} or {@code maxCapacity} is greater than the maximum
  allowed count for a {@link java.nio.ByteBuffer} - {@code Integer.MAX_VALUE - 5}
  
  @see DirectBuffer#allocate()
  @see DirectBuffer#allocate(long)