spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JoshRosen <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-3885] Provide mechanism to remove accum...
Date Fri, 20 Feb 2015 20:27:30 GMT
Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4021#discussion_r25100214
  
    --- Diff: core/src/test/scala/org/apache/spark/AccumulatorSuite.scala ---
    @@ -135,5 +137,22 @@ class AccumulatorSuite extends FunSuite with Matchers with LocalSparkContext
{
           resetSparkContext()
         }
       }
    +  
    +  test ("garbage collection") {
    +    // Create an accumulator and let it go out of scope to test that it's properly garbage
collected
    +    sc = new SparkContext("local", "test")
    +    var acc: Accumulable[mutable.Set[Any], Any] = sc.accumulable(new mutable.HashSet[Any]())
    +    val accId = acc.id
    +    val ref = WeakReference(acc)
    +
    +    // Ensure the accumulator is present
    +    assert(ref.get.isDefined)
    +
    +    // Remove the explicit reference to it and allow weak reference to get garbage collected
    +    acc = null
    +    System.gc()
    +    assert(ref.get.isEmpty)
    +    assert(Accumulators.originals.get(accId).isDefined)
    --- End diff --
    
    I guess this indicates that we don't garbage-collect the map entry that points to the
weak accumulator reference.  This memory leak isn't quite as huge of a concern as leaking
the accumulator itself, since we expect the map entry to be a small, fixed-size record (a
couple hundred bytes, max, probably).
    
    If we do decide to clean this up, though, we can probably do it by adding a synchronized
method to the Accumulators object that removes an accumulator, then register a cleanup task
with ContextCleaner when creating an accumulator.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message