Tuesday, May 19, 2009

GWT-Compiler Ant Out-Of-Memory

StackTrace (Ant)
gwt-compile:
[echo] env.GWT_HOME=C:\data\java\tools\gwt-windows-1.5.3
[java] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[java] at java.util.Arrays.copyOf(Arrays.java:2882)
[java] at java.lang.String.(String.java:179)
[java] at java.lang.String.valueOf(String.java:2841)
[java] at com.google.gwt.dev.javac.CompiledClass.(CompiledClass.java:88)
[java] at com.google.gwt.dev.javac.CompilationUnit$FindTypesInCud.visit(CompilationUnit.java:111)
[java] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1181) [java]
....


Possible Issue and Solution

In order to invoke the gwt-compiler via an Ant task successfully, you will probably need to increase the maximum memory as follows:

<target name="gwt-compile" description="...">
<java classname="com.google.gwt.dev.GWTCompiler" fork="true” maxmemory="256m" failonerror="true">
<arg line="-out ${build}/www" />
<arg value="${gwt.module}" />
<classpath refid="gwt.classpath" />
</java>
</target>