Skip to content

Commit 75905c5

Browse files
Jim Carrollsrowen
authored andcommitted
[SPARK-7100] [MLLIB] Fix persisted RDD leak in GradientBoostTrees
This fixes a leak of a persisted RDD where GradientBoostTrees can call persist but never unpersists. Jira: https://issues.apache.org/jira/browse/SPARK-7100 Discussion: http://apache-spark-developers-list.1001551.n3.nabble.com/GradientBoostTrees-leaks-a-persisted-RDD-td11750.html Author: Jim Carroll <[email protected]> Closes apache#5669 from jimfcarroll/gb-unpersist-fix and squashes the following commits: 45f4b03 [Jim Carroll] [SPARK-7100][MLLib] Fix persisted RDD leak in GradientBoostTrees
1 parent 7f3b3b7 commit 75905c5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mllib/src/main/scala/org/apache/spark/mllib/tree/GradientBoostedTrees.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ object GradientBoostedTrees extends Logging {
177177
treeStrategy.assertValid()
178178

179179
// Cache input
180-
if (input.getStorageLevel == StorageLevel.NONE) {
180+
val persistedInput = if (input.getStorageLevel == StorageLevel.NONE) {
181181
input.persist(StorageLevel.MEMORY_AND_DISK)
182-
}
182+
true
183+
} else false
183184

184185
timer.stop("init")
185186

@@ -265,6 +266,9 @@ object GradientBoostedTrees extends Logging {
265266

266267
logInfo("Internal timing for DecisionTree:")
267268
logInfo(s"$timer")
269+
270+
if (persistedInput) input.unpersist()
271+
268272
if (validate) {
269273
new GradientBoostedTreesModel(
270274
boostingStrategy.treeStrategy.algo,

0 commit comments

Comments
 (0)