We have a Maven build that runs the GWT plugin (gwt-maven). Unfortently it is running out of memory.
Do I need to give Maven itself more heap or do I need to give GWT more heap? Any idea how to specify this for a pom.xml file?
It is possible to start Maven and sbt with increased memory. We recommend you increase the Maximum Metaspace size and the Thread Stack size. These values can be set using -Xss2M -XX:MaxMetaspaceSize=1024M . The exact values may depend on your hardware and your code base.
Once you have Maven installed in your system, the very next step is to fine-tune it for an optimal performance. By default, the maximum heap allocation is 512 MB, which starts from 256 MB ( -Xms256m to -Xmx512m ).
The Maven Plugin for GWT aims at making it easier to build GWT projects with Maven, by providing specific goals, lifecycles, and artifact handlers. Java code in GWT falls into two buckets: code that's shared between the client and server (RPC interfaces and DTOs, RequestFactory interfaces, and other shared code), and.
I assume extraJvmArgs
option should be configured.
Add extraJvmArgs tag under configuration tag for gwt-maven-plugin.
Example -
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
</dependency>
</dependencies>
<!-- JS is only needed in the package phase, this speeds up testing -->
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>app.html</runTarget>
<!-- Turning This on after understanding soyc and when deferredjs count is 48.cache.js -->
<!-- https://developers.google.com/web-toolkit/articles/fragment_merging -->
<fragmentCount>25</fragmentCount>
-->
<!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
<!-- Turn This on for generating soyc. This does not work if closure compiler is turned on.-->
<!-- Start Generating SOYC -->
<compileReport>true</compileReport>
<compilerMetrics>true</compilerMetrics>
<soycDetailed>true</soycDetailed>
<!-- End Generating SOYC -->
<disableCastChecking>true</disableCastChecking>
<disableClassMetadata>true</disableClassMetadata>
<enableClosureCompiler>true</enableClosureCompiler>
<optimizationLevel>9</optimizationLevel>
<style>${gwt.style}</style>
<module>${gwtModule}</module>
<encoding>${project.build.sourceEncoding}</encoding>
<strict>true</strict>
<logLevel>INFO</logLevel>
<copyWebapp>true</copyWebapp>
<hostedWebapp>
${project.build.directory}/${project.artifactId}
</hostedWebapp>
<extraJvmArgs>-Xmx896M -Xms896m -XX:PermSize=64m -XX:MaxPermSize=128m</extraJvmArgs>
<!-- <extraJvmArgs>-Xmx896M -Xms896m -XX:PermSize=64m -XX:MaxPermSize=128m -XX:+UseConcMarkSweepGC -server</extraJvmArgs> -->
</configuration>
</plugin>
I had this error with a large GWT project. The error that you will probably see when running out of memory is:
[ERROR] OutOfMemoryError: Increase heap size of lower gwt.jjs.maxThreads
java.lang.OutOfMemoryError: Java heap space
The extraJvmArgs
option needs to be set in conjunction with the MAVEN_OPTS
environment variable (this is a possible explanation). I also set the Java -Dgwt.compiler.localWorkers=x
option to reduce the number of concurrent compilation threads (I set x to 1, but you can play with it to find something that works).
For an example of the settings you should use with the extraJvmArgs option, see this post.
Note that you may need to add the extraJvmArgs option to the plugin element configuration directly - see https://stackoverflow.com/a/5822929/157605.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With