xuechendi commented on a change in pull request #32534:
URL: https://github.com/apache/spark/pull/32534#discussion_r636076113



##########
File path: core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala
##########
@@ -385,9 +390,33 @@ private[spark] class MemoryStore(
     }
   }
 
+  def manual_close[T <: MemoryEntry[_]](entry: T): T = {
+    val entryManualCloseTasks = Future {
+      entry match {
+        case e: DeserializedMemoryEntry[_] => e.value.foreach {
+          case o: AutoCloseable =>
+            try {
+              o.close
+            } catch {
+              case NonFatal(e) =>
+                logWarning(s"Got NonFatal exception during remove")
+            }
+          case _ =>
+        }
+        case _ =>
+      }
+    }
+    entryManualCloseTasks.onComplete {

Review comment:
       @srowen , using onComplete should be non-blocking, I tested with my own 
cluster by below codes:
   If onComplete is not prefered, I am happy to change to something else, do 
you have any suggestion? 
   
   ```
       memoryStore.clear
       // Check if allocator was cleared.
       while (allocator.getAllocatedMemory > 0) {
         System.out.println(s"memoryStore clear start, wait it to finish.")
         Thread.sleep(500)
       }
       System.out.println(s"memoryStore clear finish.")
       assert(allocator.getAllocatedMemory == 0)
   ```
   
   and see output like this
   
![image](https://user-images.githubusercontent.com/4355494/118982083-a5f96d80-b9ad-11eb-9251-2c97c036b959.png)
   
   




-- 
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to