已使用 scala 终端中的 rdd.cache() 方法缓存的 RDD 正在存储在内存中。
这意味着它将消耗一部分可供 Spark 进程本身使用的内存。
话说如果内存有限,缓存的RDD越来越多,spark什么时候会自动清理已经被rdd缓存占用的内存呢?
最佳答案
Spark 将清理缓存的 RDD
和 Datasets
/DataFrames
:
- 当通过调用
RDD.unpersist
( How to uncache RDD? )/Dataset.unpersist
方法或Catalog.clearCache
明确要求时。 定期,由 cache cleaner :
Spark automatically monitors cache usage on each node and drops out old data partitions in a least-recently-used (LRU) fashion. If you would like to manually remove an RDD instead of waiting for it to fall out of the cache, use the RDD.unpersist() method.
当相应的分布式数据结构被垃圾回收时。
关于apache-spark - Spark 什么时候会自动清理缓存的 RDD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47695368/