Skip to content

Commit 00c98e0

Browse files
committed
Making the Java ObjectStreamSerializer reset rate configurable by the system variable 'spark.serializer.objectStreamReset', default is not 10000.
1 parent 40fe1d7 commit 00c98e0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/main/scala/org/apache/spark/serializer/JavaSerializer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ import org.apache.spark.SparkConf
2626
private[spark] class JavaSerializationStream(out: OutputStream) extends SerializationStream {
2727
val objOut = new ObjectOutputStream(out)
2828
var counter = 0
29+
val counterReset = System.getProperty("spark.serializer.objectStreamReset", "10000").toLong
30+
2931
/* Calling reset to avoid memory leak:
3032
* http://stackoverflow.com/questions/1281549/memory-leak-traps-in-the-java-standard-api
3133
* But only call it every 1000th time to avoid bloated serialization streams (when
3234
* the stream 'resets' object class descriptions have to be re-written)
3335
*/
3436
def writeObject[T](t: T): SerializationStream = {
3537
objOut.writeObject(t)
36-
if (counter >= 1000) {
38+
if (counterReset > 0 && counter >= counterReset) {
3739
objOut.reset()
3840
counter = 0
3941
} else {

0 commit comments

Comments
 (0)