Github user ilganeli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4021#discussion_r25116499
  
    --- 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 --
    
    Hi Josh, how do I register a cleanup task ? I see a private method within 
ContextCleaner: registerForCleanup , that it seems I can use but I don't have 
visibility of that method within the Accumulator class. How would you recommend 
doing this?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to