diff options
author | Matt Whelan <mwhelan@perka.com> | 2015-02-17 00:59:49 +0000 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2015-02-17 00:59:49 +0000 |
commit | 1294a6e01af0d4f6678ea8cb5d47dc97112608b5 (patch) | |
tree | a16772bc390b8ae71f89eb00b67c765c7156376d | |
parent | e189cbb052d59eb499dd4312403925fdd72f5718 (diff) | |
download | spark-1294a6e01af0d4f6678ea8cb5d47dc97112608b5.tar.gz spark-1294a6e01af0d4f6678ea8cb5d47dc97112608b5.tar.bz2 spark-1294a6e01af0d4f6678ea8cb5d47dc97112608b5.zip |
SPARK-5848: tear down the ConsoleProgressBar timer
The timer is a GC root, and failing to terminate it leaks SparkContext
instances.
Author: Matt Whelan <mwhelan@perka.com>
Closes #4635 from MattWhelan/SPARK-5848 and squashes the following commits:
2a1e8a5 [Matt Whelan] SPARK-5848: teardown the ConsoleProgressBar timer
-rw-r--r-- | core/src/main/scala/org/apache/spark/SparkContext.scala | 1 | ||||
-rw-r--r-- | core/src/main/scala/org/apache/spark/ui/ConsoleProgressBar.scala | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index 24a316e40e..fd8fac6df0 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -1363,6 +1363,7 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli cleaner.foreach(_.stop()) dagScheduler.stop() dagScheduler = null + progressBar.foreach(_.stop()) taskScheduler = null // TODO: Cache.stop()? env.stop() diff --git a/core/src/main/scala/org/apache/spark/ui/ConsoleProgressBar.scala b/core/src/main/scala/org/apache/spark/ui/ConsoleProgressBar.scala index 27ba9e1823..67f572e793 100644 --- a/core/src/main/scala/org/apache/spark/ui/ConsoleProgressBar.scala +++ b/core/src/main/scala/org/apache/spark/ui/ConsoleProgressBar.scala @@ -28,7 +28,6 @@ import org.apache.spark._ * of them will be combined together, showed in one line. */ private[spark] class ConsoleProgressBar(sc: SparkContext) extends Logging { - // Carrige return val CR = '\r' // Update period of progress bar, in milliseconds @@ -121,4 +120,10 @@ private[spark] class ConsoleProgressBar(sc: SparkContext) extends Logging { clear() lastFinishTime = System.currentTimeMillis() } + + /** + * Tear down the timer thread. The timer thread is a GC root, and it retains the entire + * SparkContext if it's not terminated. + */ + def stop(): Unit = timer.cancel() } |