HyukjinKwon commented on a change in pull request #25262:
[SPARK-28486][CORE][PYTHON] Map PythonBroadcast's data file to a BroadcastBlock
to avoid delete by GC
URL: https://github.com/apache/spark/pull/25262#discussion_r309005501
##########
File path: python/pyspark/tests/test_broadcast.py
##########
@@ -82,6 +83,21 @@ def test_broadcast_value_driver_no_encryption(self):
def test_broadcast_value_driver_encryption(self):
self._test_broadcast_on_driver(("spark.io.encryption.enabled", "true"))
+ def test_broadcast_value_against_gc(self):
+ """Test broadcast value against gc."""
+ conf = SparkConf()
+ conf.setMaster("local[1,1]")
+ conf.set("spark.memory.fraction", "0.0001")
+ self.sc = SparkContext(conf=conf)
+ b = self.sc.broadcast([100])
+ self.sc.parallelize([0], 1).map(lambda x: 0 if x == 0 else
b.value[0]).collect()
+ self.sc._jvm.java.lang.System.gc()
+ time.sleep(5)
+ self.sc._jvm.java.lang.System.gc()
+ time.sleep(5)
+ self.sc.parallelize([1], 1).map(lambda x: 0 if x == 0 else
b.value[0]).collect()
+ b.destroy()
Review comment:
I would put this in `finally`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]