【问题标题】:Maven build OutOfMemoryError Chunck::newMaven 构建 OutOfMemoryError Chunck::new
【发布时间】:2011-01-17 16:14:26
【问题描述】:

每次我尝试构建一个小项目(我们的 sdk)时都会出错。我已将 MAVEN_OPTS 设置为 -Xms1024m -Xmx1536m,并且我的两个硬盘驱动器上都有 6-12 GB 的交换空间(总共 24 GB)。我的盒子上有 6 GB 的物理内存,其中分配了 4 GB ......所以我真的不认为我应该得到这个错误!当我构建我的主项目时,我也会收到 OutOfMemoryError,但是当我再次构建时,它会完成构建。这个项目不会完成。有什么帮助吗?

操作系统信息:

Apache Maven 2.2.1 (r801777; 2009-08-06 13:16:01-0600)
Java version: 1.6.0_22
Java home: C:\PROGRA~2\Java\jdk1.6.0_22\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"

堆栈跟踪:

c:\dev\fi\fbisdk>mvn -e
+ Error stacktraces are turned on.
...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: java.lang.OutOfMemoryError

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: An Ant BuildException has occured: java.lang.OutOfMemoryError
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: java.lang.OutOfMemoryError
        at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:131)
        at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more
Caused by: java.lang.OutOfMemoryError
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
        ... 20 more
Caused by: java.lang.OutOfMemoryError
        at java.util.zip.Inflater.init(Native Method)
        at java.util.zip.Inflater.<init>(Inflater.java:83)
        at org.apache.tools.zip.ZipFile.getInputStream(ZipFile.java:236)
        at org.apache.tools.ant.taskdefs.Zip.addResources(Zip.java:804)
        at org.apache.tools.ant.taskdefs.Zip.addResources(Zip.java:853)
        at org.apache.tools.ant.taskdefs.Zip.executeMain(Zip.java:499)
        at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:414)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        ... 23 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
#
# A fatal error has been detected by the Java Runtime Environment:
#
# java.lang.OutOfMemoryError: requested 38168 bytes for Chunk::new. Out of swap space?
#
#  Internal Error (allocation.cpp:215), pid=6384, tid=600
#  Error: Chunk::new
#
# JRE version: 6.0_22-b04
# Java VM: Java HotSpot(TM) Client VM (17.1-b03 mixed mode windows-x86 )
# An error report file with more information is saved as:
# c:\dev\fi\fbisdk\hs_err_pid6384.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.

【问题讨论】:

  • 你能发布你的 pom.xml 中与调用 antrun 和构建 zip 文件有关的部分吗?
  • Java 需要连续内存,在 32 位系统上,当您尝试获得超过 1.3 GB 时,这可能很难获得。我建议您尝试 64 位 Java(在 64 位操作系统上),您应该不会看到这个问题。

标签: java exception maven


【解决方案1】:

我不知道这是否是您问题的根源,但是 -Xmx 设置了 max 内存。设置得更高。如果它设置得太低,你会得到 OutOfMemory 异常。并保持 Xms 小,因为它可能会增加问题。

此外,看看这些提示,可能会有用:

http://rimuhosting.com/knowledgebase/linux/java/-Xmx-settings

【讨论】:

  • 谢谢。我实际上删除了最大内存,只留下了最小值。它解决了副项目中的问题,但是当我在 first 时间对主项目进行干净构建时仍然遇到问题。在第二次尝试构建它时。
【解决方案2】:

您应该使用 -X 选项对其进行调试,这应该会为您提供更多信息。

【讨论】:

    【解决方案3】:

    您似乎正在从您的 Maven 构建中执行 ant 构建。如果 ant 构建是分叉的,它不会考虑您的 MAVEN_OPTS。您应该能够将类似的内存设置传递给 ant 构建,以便为其提供额外的内存。

    【讨论】:

      【解决方案4】:

      Java 需要连续的内存,在 32 位系统上,当您尝试获得超过 1.3 GB 的内存并且已经运行了许多程序时,这可能很难获得。建议你试试

      • 当你的内存大部分空闲时,在运行其他任何东西之前运行 maven,
      • 在 64 位 Java 上(在 64 位操作系统上),您应该不会看到这个问题。

      【讨论】:

        【解决方案5】:

        http://practicalcloudcomputing.com/post/444939181/outofmemoryjnigzip

        重点是“This OutOfMemoryError is not java.lang.OutOfMemoryError: Java heap space。当你所有可达的Java对象占用的内存超过max heap -Xmx设置时抛出后者”

        【讨论】:

          【解决方案6】:

          你在使用 maven-antrun-plugin 吗?那么你的错误不是来自Maven。因此 MAVEN_OPTS 没用。您必须在 pom.xml 中 antrun-plungin 的 java 任务中设置参数 maxmemory="1024m" (或任何适合您需要的值)。

          <plugin>
            <artifactId>maven-antrun-plung</artifactId>
            <executions>
              <execution>
              ...
                <configuration>
                ...
                  <tasks>
                  ...
                    <java classname="..." fork="true" maxmemory="1024m" ...>
                    ...
                    </java>
                  </tasks>
                </configuration>
              </execution>
              ...
            </executions>
          </plugin>
          

          【讨论】:

            猜你喜欢
            • 2011-01-04
            • 2017-01-25
            • 1970-01-01
            • 2014-05-31
            • 2014-10-22
            • 1970-01-01
            • 2019-03-21
            • 1970-01-01
            相关资源
            最近更新 更多