code: void realloc(boolean throwIfFail) {
          // Double the capacity while it is "sufficiently small", and otherwise increase by 50%.
          int newLength = capacity <= 65536 ? capacity << 1 : capacity + capacity >> 1;
  
          try {
              ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(calculateBufferCapacity(newLength));
              // Copy over the old content of the memory and reset the position as we always act on the buffer as if
              // the position was never increased.
              memory.position(0).limit(size);
              buffer.put(memory);
              buffer.position(0);
  
              Buffer.free(memory);
              memory = buffer;
              memoryAddress = Buffer.memoryAddress(buffer);
          } catch (OutOfMemoryError e) {
              if (throwIfFail) {
                  OutOfMemoryError error = new OutOfMemoryError(
                          "unable to allocate " + newLength + " new bytes! Existing capacity is: " + capacity);
                  error.initCause(e);
                  throw error;
              }
          }
      }
docs: Increase the storage of this {@link KQueueEventArray}.