private void processStopped() {
      try {
        if (!runFinished.await(30, TimeUnit.SECONDS)) {
          logger.info("{}: Dispatcher for {} didn't stop after 30s.", impl.getThisNode(), peer);
        }
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
      long requestSize = 0;
      for (IndexedConsensusRequest indexedConsensusRequest : pendingEntries) {
        requestSize += indexedConsensusRequest.getMemorySize();
      }
      pendingEntries.clear();
      iotConsensusMemoryManager.free(requestSize, true);
      requestSize = 0;
      for (IndexedConsensusRequest indexedConsensusRequest : bufferedEntries) {
        requestSize += indexedConsensusRequest.getMemorySize();
      }
      iotConsensusMemoryManager.free(requestSize, true);
      syncStatus.free();
      MetricService.getInstance().removeMetricSet(logDispatcherThreadMetrics);
    }
try to remove a request from queue with memory control.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/LogDispatcher.java