[英]Spark Driver is not releasing memory
在我們的Spark Streaming工作中,驅動程序內存始終會累積,並且永遠不會釋放。 我們已經放入G1垃圾收集來進行有效的垃圾收集,但是仍然無效。 內存總是會增加在某些時候因OOM問題而失敗的容器。 有哪些釋放驅動程序內存的選項? 請查看grafana中spark驅動程序的內存使用趨勢。
任何幫助表示贊賞。
"header_cols": "xxx1,xxx2,xxx3,xxx4",
"line_cols": "yyyy1,yyyy2,yyyy3,yyyy4,yyyy4,yyyy5,yyyy6",
"key" : "transaction_id"
/* header, line and transaction_id columns are part of the same record. The application generates a nested json grouped by transaction_id, header_cols and array of transaction_id and line cols as shown below.
|-transaction_id
|-header_cols
|- record 1 - line columns
|- record 2 - line columns
|- record 3 - line columns
*/
Spark高度依賴RAM,而不是像hadoop一樣在HDD上存儲數據,Spark將數據存儲在RAM上。
通常最好的方法是將.cache()用於將要多次使用的RDD / Dataframe。 這樣,您可以減少不必要的內存使用並加快數據訪問時間。
按照您的要求,可以在不使用的RAM上釋放/釋放RDD / Dataframe。 您可以簡單地使用“ unpersist()”,如此處所示。
rdd.unpersist()
此代碼將從RAM中刪除RDD / Dataframe。 請注意,如果您的數據很重要或已被處理,則可能需要使用以下命令將最終版本存儲在HDD / SDD中:
df.coalcase(1).write.format(“ CSV / JSON / etc”)。option(“ header”,“ true”)。save(“ path”)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.