Over a million developers have joined DZone.
Platinum Partner

GWT Compiler Is Running Out of Memory

· Performance Zone

The Performance Zone is brought to you in partnership with New Relic. New Relic APM provides constant monitoring of your apps so you don't have to.

As part of evaluating an open-source framework which uses Google Web Toolkit I ran into some of the familiar issues I already had a few times earlier with the GWT (GWT 2.4 or 2.5) Maven plugin compilation running out of memory. You know, when you see…

…at the start:

[INFO] # There is insufficient memory for the Java Runtime Environment to continue.
[INFO] # Native memory allocation (malloc) failed to allocate 32744 bytes for ChunkPool::allocate

…or during compilation:

[INFO]  Compiling 12 permutations
[INFO]  Compiling permutation 1...
[INFO]  Process output
[INFO]  Error occurred during initialization of VM
[INFO]  Could not reserve enough space for object heap

This post is basically a compilation of the answers found online, and a quick reminder for myself and others who are running into similar problems with the fantastic GWT compiler :-) .

1. First of all, check if you actually need to compile everything! Skip some browsers or locales – saving all kinds of permutations – if you don’t need it for development. Use the tips about how to speed up the GWT compiler and GWT compilation performance. There’s also an existing FAQ about GWT Debugging and Compiling.If you have control of your machine, cut down on other running applications and processes while you’re compiling.

2. Pass along some more memory

…to Maven, e.g.:

MAVEN_OPTS=-Xms1024m -Xmx1024m -XX:MaxPermSize=256m

…and/or to the gwt-maven-plugin, e.g.:

  <extraJvmArgs>-Xms768m -Xmx768m</extraJvmArgs>

You’ll have to play a bit with the values, depending on the machine you’re working on and the actually available working RAM.

Add some permgen space, which is used when GWT compiles Java into Javascript. E.g.


3. Try lowering the number of workers to a number explicitly below your available cores/cpu’s. If this number isn’t defined explicitly, the gwt-maven-plugin will set these to the number of available cores/cpu’s. Less workers = less parallellisation = less memory overhead.

  <extraJvmArgs>-Xms768m -Xmx768m</extraJvmArgs>

4. Try having the “workers” work in threads, instead of spawning new processes.

  <extraJvmArgs>-Xms768m -Xmx768m -Dgwt.jjs.permutationWorkerFactory=com.google.gwt.dev.ThreadedPermutationWorkerFactory</extraJvmArgs>

Hopefully this will save someone some valuable time finding solutions. If you have other options, feel free to add them in the comments.

Original article: http://tedvinke.wordpress.com/2013/03/21/gwt-compiler-is-running-out-of-memory 

The Performance Zone is brought to you in partnership with New Relic. New Relic’s SaaS-based Application Performance Monitoring helps you build, deploy, and maintain great web software.


Published at DZone with permission of Ted Vinke .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}