title: Java heap space OutOfMemoryError in pyspark spark-submit?
body: <p>I have a data set size of 10GB(example Test.txt).</p>
  
  <p>I wrote my pyspark script like below(Test.py):</p>
  
  <pre><code>from pyspark import SparkConf
  from pyspark.sql import SparkSession
  from pyspark.sql import SQLContext
  spark = SparkSession.builder.appName("FilterProduct").getOrCreate()
  sc = spark.sparkContext
  sqlContext = SQLContext(sc)
  lines = spark.read.text("C:/Users/test/Desktop/Test.txt").rdd
  lines.collect()
  </code></pre>
  
  <p>Then I am executing the above script using below command :</p>
  
  <pre><code>spark-submit Test.py --executor-memory  12G 
  </code></pre>
  
  <p>Then I am getting error like below:</p>
  
  <pre><code>17/12/29 13:27:18 INFO FileScanRDD: Reading File path: file:///C:/Users/test/Desktop/Test.txt, range: 402653184-536870912, partition values: [empty row]
  17/12/29 13:27:18 INFO CodeGenerator: Code generated in 22.743725 ms
  17/12/29 13:27:44 ERROR Executor: Exception in task 1.0 in stage 0.0 (TID 1)
  java.lang.OutOfMemoryError: Java heap space
          at java.util.Arrays.copyOf(Arrays.java:3230)
          at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
          at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
          at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
          at org.apache.spark.util.ByteBufferOutputStream.write(ByteBufferOutputStream.scala:41)
          at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
          at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1189)
          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
          at org.apache.spark.serializer.JavaSerializationStream.writeObject(JavaSerializer.scala:43)
          at org.apache.spark.serializer.JavaSerializerInstance.serialize(JavaSerializer.scala:100)
          at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:383)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
  17/12/29 13:27:44 ERROR Executor: Exception in task 2.0 in stage 0.0 (TID 2)
  java.lang.OutOfMemoryError: Java heap space
          at java.util.Arrays.copyOf(Arrays.java:3230)
          at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
          at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93
  </code></pre>
  
  <p>Please let me know how to resolve this? </p>