Subscription: close memory block for previous tsfile response (#14909)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/response/SubscriptionEventTsFileResponse.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/response/SubscriptionEventTsFileResponse.java index 0788a89..5cc7f40 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/response/SubscriptionEventTsFileResponse.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/response/SubscriptionEventTsFileResponse.java
@@ -81,10 +81,15 @@ @Override public void fetchNextResponse(final long offset) throws Exception { generateNextTsFileResponse(offset).ifPresent(super::offer); - if (Objects.isNull(poll())) { + + // poll and clean previous response + final CachedSubscriptionPollResponse previousResponse; + if (Objects.isNull(previousResponse = poll())) { LOGGER.warn( "SubscriptionEventTsFileResponse {} is empty when fetching next response (broken invariant)", this); + } else { + previousResponse.closeMemoryBlock(); } }