public synchronized IMemoryBlock exactAllocateIfSufficient(
      String name, long sizeInBytes, float maxRatio, MemoryBlockType memoryBlockType) {
    if (maxRatio < 0.0f || maxRatio > 1.0f) {
      return null;
    }
    if (!enabled) {
      return getOrRegisterMemoryBlock(name, sizeInBytes, memoryBlockType);
    }
    if (totalMemorySizeInBytes - allocatedMemorySizeInBytes >= sizeInBytes
        && (float) allocatedMemorySizeInBytes / totalMemorySizeInBytes < maxRatio) {
      return exactAllocate(name, sizeInBytes, memoryBlockType);
    } else {
      // TODO @spricoder: consider to find more memory in active way
      LOGGER.debug(
          "exactAllocateIfSufficient: failed to allocate memory, "
              + "total memory size {} bytes, used memory size {} bytes, "
              + "requested memory size {} bytes, used threshold {}",
          totalMemorySizeInBytes,
          allocatedMemorySizeInBytes,
          sizeInBytes,
          maxRatio);
    }

    return null;
  }
Try to allocate memory block with specified size in bytes when the proportion of used memory is
below the given maxRatio.

@param name the name of memory block
@param sizeInBytes the size in bytes of memory block try to allocate
@param maxRatio the used threshold of allocatedMemorySizeInBytes / totalMemorySizeInBytes, must
    be within [0.0, 1.0
@param memoryBlockType the type of memory block
@return the memory block if success, otherwise null
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java