You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/02/18 07:24:01 UTC

[GitHub] [iotdb] HeimingZ commented on a change in pull request #5085: [IOTDB-2567] Fix thread and ByteBuffer leak after service stopped

HeimingZ commented on a change in pull request #5085:
URL: https://github.com/apache/iotdb/pull/5085#discussion_r809732797



##########
File path: server/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
##########
@@ -171,6 +178,26 @@ public void close() {
     }
   }
 
+  @Override
+  public void release() {
+    ThreadUtils.stopThreadPool(FLUSH_BUFFER_THREAD_POOL, WAL_FLUSH);
+    lock.lock();
+    try {
+      if (this.logBufferWorking != null && this.logBufferWorking instanceof MappedByteBuffer) {
+        MmapUtil.clean((MappedByteBuffer) this.logBufferFlushing);
+      }
+      if (this.logBufferIdle != null && this.logBufferIdle instanceof MappedByteBuffer) {
+        MmapUtil.clean((MappedByteBuffer) this.logBufferIdle);
+      }
+      if (this.logBufferFlushing != null && this.logBufferFlushing instanceof MappedByteBuffer) {
+        MmapUtil.clean((MappedByteBuffer) this.logBufferFlushing);
+      }

Review comment:
       Excellent work! But ByteBuffers here are controlled by VirtualStorageGroupProcessor, whose releaseWalDirectByteBufferPool method also frees these ByteBuffers.
   ```
   public void releaseWalDirectByteBufferPool() {
     synchronized (walByteBufferPool) {
       while (!walByteBufferPool.isEmpty()) {
         MmapUtil.clean((MappedByteBuffer) walByteBufferPool.removeFirst());
         currentWalPoolSize--;
       }
     }
   }
   ```




-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org