John156
John156

Reputation: 83

java heap space

do you have any idea why I could get a 'Exception in thread "main" java.lang.OutOfMemoryError: Java heap space' error when building my android app, even though I added -vmargs -Xmx1024M -Xms512M to the eclipse arguments ? I would like to know what error could I have made that would trigger such an error at build time, as it would appear to me that only a bug in eclipse or maven could produce such an error at build time. I am using run as maven install to build my application (with the maven android eclipse plugin). Run as-> 'maven package' also produces the same build failure, after waiting roughly 1min30. I have a desktop computer with 3GB of memory, and my application isn't nearly that big.

Thanks.

Upvotes: 5

Views: 10116

Answers (4)

gilsaints88
gilsaints88

Reputation: 1160

I experienced this Conversion to Dalvik format failed: Unable to execute dex: Java heap space. increasing the all of the values in the eclipse.ini file didn't help. This happened to me after I upgraded my ADT plugin from 12 to 16. I changed the Android SDKs that were pointed to my existing projects prior to the upgrade (from the android sdks that were connected on my previous adt I changed them to the android sdks that were connected to my new adt) and it solved the issue for me. hope this helps. and if it helps someone please vote for plus 1 this.

Upvotes: 1

Mustafa Güven
Mustafa Güven

Reputation: 15744

If increasing does not respond then I would suggest to you that check the line count for each class you wrote. It can be a compiler problem if there are a lot of objects so try to partitioning methods and/or copy them into new classes if one or more of the classes have 3000+ lines.

Upvotes: 0

dogbane
dogbane

Reputation: 274612

Add -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/some/path to your jvm args so that when it runs out of memory it will dump out the heap. You can then use Eclipse Memory Analyser or jhat to browse the heap and diagnose where the problem might be.

Update: Try increasing the memory of your maven android plugin. In your pom.xml, add a JVM argument for Xmx to the plugin configuration:

<plugin>
  <artifactId>maven-android-plugin</artifactId>
  <configuration>
    <jvmArguments>
      <argument>-Xmx1500m</argument>
    </jvmArguments>
  </configuration>
</plugin>

Upvotes: 8

Stefan Schubert-Peters
Stefan Schubert-Peters

Reputation: 5459

Your Eclipse JVM arguments do not matter. You have to increase the heap of the compiler.

I am quoting http://javahowto.blogspot.com/2006/06/fix-javac-java-lang-outofmemoryerror.html

If [...] you're running Eclipse, go into your "run As" dialog for your Build.xml and add -Xms256m -Xmx256m to the "VM Arguments" text box

Upvotes: 2

Related Questions