For Spark 1.1.1+, to set the Max Memory of workers. You need to write this in conf/spark.env.sh:
export SPARK_EXECUTOR_MEMORY=2G
Also, check if you have not used the config file yet, then copy the template file first, as mentioned below:
cp conf/spark-env.sh.template conf/spark-env.sh
Then make the change and don't forget to source it
source conf/spark-env.sh