@SuppressWarnings("squid:S3518")
  private void initQueryEngineMemoryAllocate(
      MemoryManager queryEngineMemoryManager, TrimProperties properties) {
    setEnableQueryMemoryEstimation(
        Boolean.parseBoolean(
            properties.getProperty(
                "enable_query_memory_estimation",
                Boolean.toString(isEnableQueryMemoryEstimation()))));
    setMetaDataCacheEnable(
        Boolean.parseBoolean(
            properties.getProperty(
                "meta_data_cache_enable", Boolean.toString(isMetaDataCacheEnable()))));
    setQueryThreadCount(
        Integer.parseInt(
            properties.getProperty("query_thread_count", Integer.toString(getQueryThreadCount()))));

    if (getQueryThreadCount() <= 0) {
      setQueryThreadCount(Runtime.getRuntime().availableProcessors());
    }
    try {
      // update enable query memory estimation for memory control
      setEnableQueryMemoryEstimation(
          Boolean.parseBoolean(
              properties.getProperty(
                  "enable_query_memory_estimation",
                  ConfigurationFileUtils.getConfigurationDefaultValue(
                      "enable_query_memory_estimation"))));

    } catch (Exception e) {
      LOGGER.error(String.format("Fail to reload configuration because %s", e));
    }

    String queryMemoryAllocateProportion =
        properties.getProperty("chunk_timeseriesmeta_free_memory_proportion");
    long maxMemoryAvailable = queryEngineMemoryManager.getTotalMemorySizeInBytes();

    long bloomFilterCacheMemorySize = maxMemoryAvailable / 1001;
    long chunkCacheMemorySize = maxMemoryAvailable * 100 / 1001;
    long timeSeriesMetaDataCacheMemorySize = maxMemoryAvailable * 200 / 1001;
    long coordinatorMemorySize = maxMemoryAvailable * 50 / 1001;
    long operatorsMemorySize = maxMemoryAvailable * 200 / 1001;
    long dataExchangeMemorySize = maxMemoryAvailable * 200 / 1001;
    long timeIndexMemorySize = maxMemoryAvailable * 200 / 1001;
    if (queryMemoryAllocateProportion != null) {
      String[] proportions = queryMemoryAllocateProportion.split(":");
      int proportionSum = 0;
      for (String proportion : proportions) {
        proportionSum += Integer.parseInt(proportion.trim());
      }
      if (proportionSum != 0) {
        try {
          bloomFilterCacheMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum;
          chunkCacheMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum;
          timeSeriesMetaDataCacheMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum;
          coordinatorMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum;
          operatorsMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum;
          dataExchangeMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[5].trim()) / proportionSum;
          timeIndexMemorySize =
              maxMemoryAvailable * Integer.parseInt(proportions[6].trim()) / proportionSum;
        } catch (Exception e) {
          throw new IllegalArgumentException(
              "Each subsection of configuration item chunkmeta_chunk_timeseriesmeta_free_memory_proportion"
                  + " should be an integer, which is "
                  + queryMemoryAllocateProportion,
              e);
        }
      }
    }

    // metadata cache is disabled, we need to move all their allocated memory to other parts
    if (!isMetaDataCacheEnable()) {
      long sum =
          bloomFilterCacheMemorySize + chunkCacheMemorySize + timeSeriesMetaDataCacheMemorySize;
      bloomFilterCacheMemorySize = 0;
      chunkCacheMemorySize = 0;
      timeSeriesMetaDataCacheMemorySize = 0;
      long partForDataExchange = sum / 2;
      long partForOperators = sum - partForDataExchange;
      dataExchangeMemorySize += partForDataExchange;
      operatorsMemorySize += partForOperators;
    }
    // set max bytes per fragment instance
    setMaxBytesPerFragmentInstance(dataExchangeMemorySize / getQueryThreadCount());

    bloomFilterCacheMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager(
            "BloomFilterCache", bloomFilterCacheMemorySize);
    chunkCacheMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager("ChunkCache", chunkCacheMemorySize);
    timeSeriesMetaDataCacheMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager(
            "TimeSeriesMetaDataCache", timeSeriesMetaDataCacheMemorySize);
    coordinatorMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager("Coordinator", coordinatorMemorySize);
    operatorsMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager("Operators", operatorsMemorySize);
    dataExchangeMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager("DataExchange", dataExchangeMemorySize);
    timeIndexMemoryManager =
        queryEngineMemoryManager.getOrCreateMemoryManager("TimeIndex", timeIndexMemorySize);
  }
The memory manager of direct Buffer
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/DataNodeMemoryConfig.java