title: How to assembly Spark on EC2 t2micro instance (and avoid "java.lang.OutOfMemoryError: Java heap space" error)?
body: <p>I'm trying to build Apache Spark on t2micro instance with <code>sbt/sbt assembly</code> and it always ends up with an error:</p>
  
  <blockquote>
    <p>[error] java.util.concurrent.ExecutionException:
    java.lang.OutOfMemoryError: Java heap space</p>
  </blockquote>
  
  <p>I've tried various tricks advised online, such as modifying <code>_JAVA_OPTS</code> to limit the memory usage, number of parallel threads and also limiting memory for <code>sbt</code> command. All this didn't help.</p>
  
  <p>I run Ubuntu 14.04 AMI. I've checked free memory with <code>free -m</code> to set up above parameters.</p>
  
  <p>Note: if I use ec2 scripts shipped with Spark distribution and specify t2.micro instance, it works fine.</p>