title: How to limit DEX memory usage
body: <p>I am trying to set the maximum memory that DEX task can use in a gradle-based Android project, but can't find any option to do that.</p>
  
  <p>My motivation to do this is because as <code>dex</code> sometimes takes so much memory that my computer starts swapping and becomes completely unresponsive for some minutes (so I would rather see the task fail and then free some more resources and retry)</p>
  
  <p>In my <code>gradle.properties</code> I have <code>org.gradle.jvmargs="-Xmx300m"</code> which limits the memory used by Gradle itself, but when Gradle starts dx it always uses <code>-Xmx1024</code>.</p>
  
  <p>So how can I make Gradle limit the memory used by dx?</p>