You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/08/11 07:36:25 UTC

[GitHub] [spark] szhem commented on a change in pull request #23083: [SPARK-26114][CORE] ExternalSorter's readingIterator field leak

szhem commented on a change in pull request #23083: [SPARK-26114][CORE] ExternalSorter's readingIterator field leak
URL: https://github.com/apache/spark/pull/23083#discussion_r312727217
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/util/CompletionIterator.scala
 ##########
 @@ -25,11 +25,14 @@ private[spark]
 abstract class CompletionIterator[ +A, +I <: Iterator[A]](sub: I) extends Iterator[A] {
 
   private[this] var completed = false
-  def next(): A = sub.next()
+  private[this] var iter = sub
+  def next(): A = iter.next()
   def hasNext: Boolean = {
-    val r = sub.hasNext
+    val r = iter.hasNext
     if (!r && !completed) {
       completed = true
+      // reassign to release resources of highly resource consuming iterators early
+      iter = Iterator.empty.asInstanceOf[I]
 
 Review comment:
   @ChenjunZou, you can find the details in this [message](https://github.com/apache/spark/pull/23083#discussion_r236057101)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org