January 24, 2008...4:33 am

GWT: increase Java heap

Jump to Comments
Francis Hans E. Mohan
January 24, 2008
We have encountered a weird problem recently. We were coding the other features of the application and everything was working fine in hosted mode. Then we tried to compile/convert it to Javascript. We got errors in our logs.
Analyzing permutation #1[ERROR] Unexpected internal compiler error
java.lang.OutOfMemoryError: Java heap space
com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
at com.google.gwt.dev.js.ast.JsVisitor.translateException(JsVisitor.java:40 8)
at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:399)
[ERROR] Out of memory; to increase the amount of memory, use the -Xmx flag at startup (java
-Xmx128M …)
[ERROR] <no source info>: function AW(b, a){
return a.relatedTarget || null;
}com.google.gwt.dev.js.ast.JsFunction
[ERROR] <no source info>: function AW(b, a){
return a.relatedTarget || null;
}
com.google.gwt.dev.js.ast.JsExprStmt
[ERROR] <no source info>: <JsProgram>
com.google.gwt.dev.js.ast.JsProgram
[ERROR] Build failed
 
The build failed. We’ve been checking the net for possible solutions to this weird problem and there were different solutions. I’ll just share what we’ve read and learned from solving this error.
  1. When you remove or comment large amounts of code, this error will disappear. This error can come out when coding big applications.
  2. Avoid using variables that are keywords in Javascript such as delete or confirm. They might work well in Java but this may cause problems when converting your Java code to javascript.
  3. According to some posts, there are times when GWT cannot convert into javascript some not-so-common-but-valid lines of Java code.
  4. Read the logs well and don’t forget to try whatever is suggested even if you think that’s not the problem and that the suggested solution is not what you need. XD
  5. To increase Java heap space, the command is java -Xmx256M myApplication
  6. To increase Java heap space in eclipse, you can edit the eclipse.ini file (I have not tried this)
  7. (Solution to our problem) To increase Java heap space in GWT when compiling to Javascript, go to the GWT compile script (ex. Home-compile.cmd). Open it with a text editor. You will see that it starts with @java -cp. Simply add the Xmx option like this: @java -Xmx256M -cp. Run the script in command prompt/console. We tried this and compilation to javascript was successful.

We were stuck in this error for quite a while. Next steps are to continue coding the rest of the application.

- eAssess group

Leave a Reply

You must be logged in to post a comment.