File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
core/src/main/scala/org/apache/spark/serializer Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -26,14 +26,16 @@ import org.apache.spark.SparkConf
26
26
private [spark] class JavaSerializationStream (out : OutputStream ) extends SerializationStream {
27
27
val objOut = new ObjectOutputStream (out)
28
28
var counter = 0
29
+ val counterReset = System .getProperty(" spark.serializer.objectStreamReset" , " 10000" ).toLong
30
+
29
31
/* Calling reset to avoid memory leak:
30
32
* http://stackoverflow.com/questions/1281549/memory-leak-traps-in-the-java-standard-api
31
33
* But only call it every 1000th time to avoid bloated serialization streams (when
32
34
* the stream 'resets' object class descriptions have to be re-written)
33
35
*/
34
36
def writeObject [T ](t : T ): SerializationStream = {
35
37
objOut.writeObject(t)
36
- if (counter >= 1000 ) {
38
+ if (counterReset > 0 && counter >= counterReset ) {
37
39
objOut.reset()
38
40
counter = 0
39
41
} else {
You can’t perform that action at this time.
0 commit comments