【问题标题】:Maven Eclipse plugin increased memory?Maven Eclipse 插件增加内存?
【发布时间】:2013-04-24 12:42:54
【问题描述】:

我在这里阅读了其他几个问题和答案,但似乎没有一个对我有帮助。我正在尝试构建一个 mgwt 项目,该项目将有很多排列,因此内存设置必须非常高。

我正在使用maven4eclipse插件以包为目标进行构建,在我的运行配置的jre选项卡上我设置了以下

vm args:-Xms1024m -Xmx2048m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=64m

尝试运行时失败并返回此错误:

[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.3.0-1:compile (default) on project: Command [[
[ERROR] **C:\Program Files\Java\jdk1.7.0_17\jre\bin\java -Xmx512m** -classpath "..others stuff" -logLevel INFO -style OBF -war "Branch(mobile)\Project\target\Mobile-webcontent" -localWorkers 8
[ERROR] ]] failed with status 1
[ERROR] -> [Help 1]

这向我表明我设置的参数没有被使用,我是否将其设置在错误的位置?

【问题讨论】:

    标签: maven gwt jvm-arguments mgwt gwt-maven-plugin


    【解决方案1】:

    用于 GWT 编译的示例 POM 文件,其中包含为大多数 GWT 编译器选项(包括 JVM 选项)配置的设置。

        <plugins>
            <!-- 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>${gwt.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-codeserver</artifactId>
                        <version>${gwt.version}</version>
                    </dependency>                   
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-dev</artifactId>
                        <version>${gwt.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-servlet</artifactId>
                        <version>${gwt.version}</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>
                    <skip>true</skip>
                    <strict>true</strict>
                    <runTarget>app.html</runTarget>
                    <!-- Turning This on after understanding soyc -->
                    <!-- https://developers.google.com/web-toolkit/articles/fragment_merging -->
                    <!-- <fragmentCount>95</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. -->
                    <compileReport>false</compileReport>
                    <compilerMetrics>false</compilerMetrics>
                    <soycDetailed>false</soycDetailed>
                    <!-- End Generating SOYC -->
                    <disableCastChecking>true</disableCastChecking>
                    <disableClassMetadata>true</disableClassMetadata>
                    <enableClosureCompiler>true</enableClosureCompiler>
                    <optimizationLevel>9</optimizationLevel>
                    <style>${gwt.style}</style>
                    <module>${gwt.module}</module>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <logLevel>INFO</logLevel>
                    <!-- ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL). -->
                    <copyWebapp>true</copyWebapp>
                    <hostedWebapp>${project.build.directory}/${project.artifactId}</hostedWebapp>
                    <extraJvmArgs>-Xmx4096M -Xms1024M -XX:PermSize=128m -XX:MaxPermSize=256m</extraJvmArgs>
                    <!-- <extraJvmArgs>-Xmx1024M -Xms1024m -Xss32m -XX:PermSize=64m -XX:MaxPermSize=128m -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -DgeneratePom=true -XX:ReservedCodeCacheSize=128m -XX:+PrintCompilation -server</extraJvmArgs> -->
                    <extra>${project.build.directory}/gwt-extra</extra>
                    <deploy>${project.build.directory}/gwt-deploy</deploy>
                    <localWorkers>4</localWorkers>
                </configuration>
            </plugin>
    

    【讨论】:

    • 我的问题是我的 localWorkers 被设置为 99 从另一个项目中提取 pom 设置。它导致了更大的问题,因为它试图保留您为每个核心指定的内存。最终我将内存设置减少到 1024 并增加了
    • localworkers 理想情况下应该少于您拥有的核心/线程数 :)
    【解决方案2】:

    gwt-maven-plugin fork 一个 JVM,不会从用于运行 Maven 的 JVM 继承设置。

    如果您需要针对分叉 JVM 的特定 JVM 设置,您可以使用 POM 中 gwt-maven-plugin&lt;configuration&gt; 中的 &lt;extraJvmArgs&gt; 或命令行中的 -Dgwt.extraJvmArgs="-Xms1g -Xmx2g" 进行设置。

    http://www.mojohaus.org/gwt-maven-plugin/compile-mojo.html#extraJvmArgs

    【讨论】:

    • 我的问题是我的 localWorkers 被设置为 99 从另一个项目中提取 pom 设置。它导致了更大的问题,因为它试图保留您为每个核心指定的内存。最终我将内存设置减少到 1024,将 localWorkers 减少到 6。
    猜你喜欢
    • 2012-08-09
    • 2020-12-17
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 2013-02-14
    • 1970-01-01
    • 2011-04-28
    • 2014-11-19
    相关资源
    最近更新 更多