I get an error every time I try and build a small project (our sdk). I have set my MAVEN_OPTS to -Xms1024m -Xmx1536m and I have a 6-12 GB of swap on both of my hard drives (so 24 GB total). I have 6 GB of physical ram on my box of which 4 GB is allocated... so I really don't think I should be getting this error! When I build my main project I get an OutOfMemoryError as well, but when I build again it completes the build. This project will not complete. Any help?
OS Info:
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"
Stack Trace:
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.
I don't know if it's the root of your problem, but -Xmx sets max memory. Set it higher. If it's set too low, you can get OutOfMemory exceptions. And keep Xms small as it may add to the problem.
Furthermore, take a peek at those hints, may prove useful:
http://rimuhosting.com/knowledgebase/linux/java/-Xmx-settings
You should debug it with the -X option, this should give you more info.
You seem to be executing an ant build from your maven build. If the ant build is forked, it doesn't take into account your MAVEN_OPTS. You should be able to pass similar memory settings to the ant build in order to provide it additional memory.
Java needs continous memory and on a 32-bit system this can be difficult to obtain when you try to get more than 1.3 GB and you have many programs running already. I suggest you try
- running maven before running anything else when your memory is mostly free,
- on 64-bit Java (on a 64-bit OS) and you shouldn't see this problem.
Look at http://practicalcloudcomputing.com/post/444939181/outofmemoryjnigzip.
The main point is "This OutOfMemoryError is not java.lang.OutOfMemoryError: Java heap space. The latter is thrown when the memory occupied by all of your reachable Java objects exceeds the max heap -Xmx setting"
are you using the maven-antrun-plugin? then your error does NOT come from maven. therefore MAVEN_OPTS is useless. you have to set the argument maxmemory="1024m" (or whatever value suits your needs) in the java task of the antrun-plungin in the pom.xml.
<plugin>
<artifactId>maven-antrun-plung</artifactId>
<executions>
<execution>
...
<configuration>
...
<tasks>
...
<java classname="..." fork="true" maxmemory="1024m" ...>
...
</java>
</tasks>
</configuration>
</execution>
...
</executions>
</plugin>
精彩评论