Thinking some more, it looks like because of the SPARK_MEM/SPARK_MEMORY typo in ExecutorRunner, this executorMemory val was effectively unused, and so the SparkContext.executorEnvs was how SPARK_MEM got shipped over to the executors.

So, the executor can (and was) being sent two ways: one implicitly in the env variables (as SPARK_MEM) and once explicitly in the LaunchExecutor message. Seems like there should be only one way? Which one is better?

I generally prefer more explicit, which is what my patch does (it overwrites any SPARK_ENV environment var with the memoryPerSlave setting).