public synchronized IMemoryBlock exactAllocate(
      String name, long sizeInBytes, MemoryBlockType type) {
    if (!enabled) {
      return getOrRegisterMemoryBlock(name, sizeInBytes, type);
    }
    for (int i = 0; i < MEMORY_ALLOCATE_MAX_RETRIES; i++) {
      if (totalMemorySizeInBytes - allocatedMemorySizeInBytes >= sizeInBytes) {
        return getOrRegisterMemoryBlock(name, sizeInBytes, type);
      }

      try {
        this.wait(MEMORY_ALLOCATE_RETRY_INTERVAL_IN_MS);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        LOGGER.warn("exactAllocate: interrupted while waiting for available memory", e);
      }
    }

    throw new MemoryException(
        String.format(
            "exactAllocate: failed to allocate memory after %d retries, "
                + "total memory size %d bytes, used memory size %d bytes, "
                + "requested memory size %d bytes",
            MEMORY_ALLOCATE_MAX_RETRIES,
            totalMemorySizeInBytes,
            allocatedMemorySizeInBytes,
            sizeInBytes));
  }
Allocate memory block with exact specified size in bytes

@param name the name of memory block
@param sizeInBytes the size in bytes of memory block try to allocate
@param type the type of memory block
@return the allocated memory block
@throw MemoryException if fail to allocate after MEMORY_ALLOCATE_MAX_RETRIES retries
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java