public void addCompactionMemoryCost(
      CompactionTaskType taskType, long memoryCost, boolean waitUntilAcquired)
      throws CompactionMemoryNotEnoughException, InterruptedException {
    if (memoryCost > compactionMemoryBlock.getTotalMemorySizeInBytes()) {
      // required memory cost is greater than the total memory budget for compaction
      throw new CompactionMemoryNotEnoughException(
          String.format(
              "Required memory cost %d bytes is greater than "
                  + "the total memory budget for compaction %d bytes",
              memoryCost, compactionMemoryBlock.getTotalMemorySizeInBytes()));
    }
    boolean allocateResult =
        waitUntilAcquired
            ? compactionMemoryBlock.allocateUntilAvailable(memoryCost, 100)
            : compactionMemoryBlock.allocate(memoryCost);
    if (!allocateResult) {
      throw new CompactionMemoryNotEnoughException(
          String.format(
              "Failed to allocate %d bytes memory for compaction, "
                  + "total memory budget for compaction module is %d bytes, %d bytes is used",
              memoryCost,
              compactionMemoryBlock.getTotalMemorySizeInBytes(),
              compactionMemoryBlock.getUsedMemoryInBytes()));
    }
    switch (taskType) {
      case INNER_SEQ:
        seqInnerSpaceCompactionMemoryCost.addAndGet(memoryCost);
        break;
      case INNER_UNSEQ:
        unseqInnerSpaceCompactionMemoryCost.addAndGet(memoryCost);
        break;
      case CROSS:
        crossSpaceCompactionMemoryCost.addAndGet(memoryCost);
        break;
      case SETTLE:
        settleCompactionMemoryCost.addAndGet(memoryCost);
        break;
      default:
    }
  }
Report resetting the mem cost of sg to system. It will be called after flushing, closing and
failed to insert

@param dataRegionInfo database
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/SystemInfo.java