【问题标题】:How would I give the GWT-compiler more memory when using GWT-Maven?使用 GWT-Maven 时如何为 GWT 编译器提供更多内存?
【发布时间】:2012-05-15 16:43:02
【问题描述】:

我们有一个运行 GWT 插件 (gwt-maven) 的 Maven 构建。不幸的是,它内存不足。

我需要给 Maven 本身更多的堆还是需要给 GWT 更多的堆?知道如何为 pom.xml 文件指定这个吗?

【问题讨论】:

    标签: gwt maven gwt-compiler gwt-maven-plugin


    【解决方案1】:

    我假设应该配置extraJvmArgs 选项。

    【讨论】:

    • 示例:设置 MAVEN_OPTS=-Dgwt.extraJvmArgs="-Xms1g -Xmx2g"
    【解决方案2】:

    在 gwt-maven-plugin 的配置标签下添加 extraJvmArgs 标签。

    示例 -

            <!-- 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>
    

    【讨论】:

      【解决方案3】:

      我在一个大型 GWT 项目中遇到了这个错误。内存不足时您可能会看到的错误是:

      [ERROR] OutOfMemoryError: Increase heap size of lower gwt.jjs.maxThreads
      java.lang.OutOfMemoryError: Java heap space
      

      extraJvmArgs 选项需要与MAVEN_OPTS 环境变量(this is a possible explanation)一起设置。我还设置了 Java -Dgwt.compiler.localWorkers=x 选项以减少并发编译线程的数量(我将 x 设置为 1,但您可以使用它来找到可行的方法)。

      有关您应与 extraJvmArgs 选项一起使用的设置示例,请参阅此post

      请注意,您可能需要直接将 extraJvmArgs 选项添加到插件元素配置中 - 请参阅 https://stackoverflow.com/a/5822929/157605

      【讨论】:

        猜你喜欢
        • 2012-10-31
        • 2012-03-14
        • 1970-01-01
        • 1970-01-01
        • 2014-12-04
        • 1970-01-01
        • 2017-11-26
        • 1970-01-01
        • 2019-02-24
        相关资源
        最近更新 更多