> For the complete documentation index, see [llms.txt](https://nag-9-s.gitbook.io/spark-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nag-9-s.gitbook.io/spark-notes/spark-application-garbage-collector.md).

# Spark Application Garbage Collector

`ContextCleaner`is a Spark service that is responsible for [application-wide cleanup](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#keepCleaning) of [shuffles](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#registerShuffleForCleanup) , [RDDs](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#registerRDDForCleanup) , [broadcasts](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#registerBroadcastForCleanup) , a[ccumulators](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#registerAccumulatorForCleanup) and [checkpointed RDDs](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#registerRDDCheckpointDataForCleanup) that is aimed at reducing the memory requirements of long-running data-heavy Spark applications.

> `ContextCleaner` runs on the driver. It is created and immediately started when [`SparkContext` starts](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-sparkcontext-creating-instance-internals.html#_cleaner) (and [`spark.cleaner.referenceTracking` Spark property](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-service-contextcleaner.html#spark_cleaner_referenceTracking) is enabled, which it is by default). It is stopped when [`SparkContext` is stopped](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-SparkContext.html#stop)

.
