title: instant run java.lang.OutOfMemoryError: GC overhead limit exceeded
body: <p>I have upgraded to Android Studio 2.1 and I got this error while I am trying to build &amp; run my corporate big project: </p>
  
  <blockquote>
    <p>Execution failed for task ':app:transformClassesWithDexForMyAppDebug'.
    com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
    java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError:
    GC overhead limit exceeded</p>
  </blockquote>
  
  <p>I have searched through the forum and disabled instant run, also write to my build.gradle: </p>
  
  <pre><code>dexOptions {
      incremental true
      javaMaxHeapSize "6g"
  }
  ...
  dependencies{
      compile 'com.android.support:multidex:'
  }
  </code></pre>
  
  <p>But it doasn't solved my problem. 
  I have multidex enabled in my gradle, because I get the error without it: </p>
  
  <blockquote>
    <p>com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536</p>
  </blockquote>
  
  <p>so this was the solution for it, and it worked before with the previous versions of Android Studio (also working for the others in the company, who are using Android Studio 1.4-2.0) but not for me since I upgraded my Android Studio. </p>
  
  <p>Do anyone have an idea what can cause the problem? </p>
  
  <p>What is also interesting that if I just make the project I don't get the error, only if I try to Run it. Any idea is appreciated!</p>
  
  <p>EDIT 1: </p>
  
  <p>What is also interesting, that if I restart my android studio, than the first run is successful, but the second is not. </p>
  
  <p>EDIT 2: </p>
  
  <p>If I set the heap size to bigger (like 8-10g) than the app not even compiles at first run.</p>
  
  <p>EDIT 3: </p>
  
  <p>It seems that the problem is with <strong>instant run</strong>, if I force android studio to not use it (like deploying to two devices at once or changeing gradle.properties like in the answer) the error disappears. </p>