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>

7 comments:

Pratik said...
This comment has been removed by the author.
Pratik said...

Does it really say out of memory, cause I've been using GWT and never encountered such error, yeah, never built using ant. Which builder does GWT uses then??

Lara said...

This only happens once you automate your build process using Ant and don't have the "maxmemory" setting defined.

How are you compiling your project? If you used ProjectCreator, you will notice that the generated *compile.cmd script has "@java -Xmx256M" so you wouldn't get the memory error.

Pratik said...

I'm using eclipse plugin that google provided, so don't know which compiler it does use internally. I've not seen much website using GWT (other than Google), I'd love to see your app.
I did a very primitive site RedditWorks.com using GWT, just for a testing purpose hardly a day work, GWT is perfect for fast and professional looks. Are you using ProjectCreator?

Lara said...

I'm using Elipse to develop, but prefer to run the hosted mode using the scripts I generated using ProjectCreator and ApplicationCreator. I like knowing how things are wired together and which java processes GWT is using to do its magic.

Anonymous said...

Hello,

I mostly visits this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]laritza-saenz-java.blogspot.com is filled with quality info. Do you pay attention towards your health?. Are you really serious about your weight?. Recent Scientific Research indicates that almost 70% of all United States grownups are either obese or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these citizens, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? Quick weight loss can be achived with little effort. Some improvement in of daily activity can help us in losing weight quickly.

About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for fast weight loss.

Anonymous said...

I'd like to find out more? I'd care to find out more details.


Here is my page - cheap cccam