SteveYurongSu commented on code in PR #13813:
URL: https://github.com/apache/iotdb/pull/13813#discussion_r1812567216


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/resource/ref/PipePhantomReferenceManager.java:
##########
@@ -55,19 +55,35 @@ protected void gcHook() {
       return;
     }
 
+    final long startTime = System.currentTimeMillis();
+
+    // limit control to avoid infinite execution
+    final int maxCount = getPhantomReferenceCount();
+    int count = 0;
+
     Reference<? extends EnrichedEvent> reference;
     try {
-      while ((reference = REFERENCE_QUEUE.remove(500)) != null) {
+      while (count < maxCount && ((reference = REFERENCE_QUEUE.remove(500)) != 
null)) {
         finalizeResource((PipeEventPhantomReference) reference);
+        count++;
       }
     } catch (final InterruptedException e) {
       // Finalize remaining references.
-      while ((reference = REFERENCE_QUEUE.poll()) != null) {
+      while (count < maxCount && ((reference = REFERENCE_QUEUE.poll()) != 
null)) {
         finalizeResource((PipeEventPhantomReference) reference);
+        count++;
       }
     } catch (final Exception e) {
       // Nowhere to really log this.
     }
+
+    if (maxCount != 0 || getPhantomReferenceCount() != 0) {
+      LOGGER.info(

Review Comment:
   Too frequent!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to