code: public static HeapBuffer allocate(int initialCapacity, int maxCapacity) {
      checkArgument(initialCapacity <= maxCapacity, "initial capacity cannot be greater than maximum capacity");
      return new HeapBuffer(HeapBytes.allocate((int) Math.min(Memory.Util.toPow2(initialCapacity), MAX_SIZE)), 0, initialCapacity, maxCapacity);
    }
docs: Allocates a new direct buffer.
  
  @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 HeapBuffer#allocate()
  @see HeapBuffer#allocate(int)