'Maven build failed with GC overhead limit exceeded
I am trying to build the project with the following command
mvn clean install
But every-time its end with memory issue ,then i run same command with -X
option and it end with follwoing detail error
[ERROR] GC overhead limit exceeded -> [Help 1] java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.Arrays.copyOf(Arrays.java:3332) at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649) at java.lang.StringBuilder.append(StringBuilder.java:202) at aQute.bnd.osgi.Clazz.parseReference(Clazz.java:1807) at aQute.bnd.osgi.Clazz.parseReferences(Clazz.java:1774) at aQute.bnd.osgi.Clazz.parseDescriptor(Clazz.java:1756) at aQute.bnd.osgi.Clazz.referTo(Clazz.java:1727) at aQute.bnd.osgi.Clazz.parseClassFileData(Clazz.java:759) at aQute.bnd.osgi.Clazz.parseClassFileData(Clazz.java:509) at aQute.bnd.osgi.Clazz.parseClassFileWithCollector(Clazz.java:494) at aQute.bnd.component.AnnotationReader.getDef(AnnotationReader.java:134) at aQute.bnd.component.AnnotationReader.getDefinition(AnnotationReader.java:130) at aQute.bnd.component.DSAnnotations.analyzeJar(DSAnnotations.java:126) at aQute.bnd.osgi.Analyzer.doPlugins(Analyzer.java:664) at aQute.bnd.osgi.Analyzer.analyze(Analyzer.java:216) at aQute.bnd.osgi.Builder.analyze(Builder.java:387) at aQute.bnd.osgi.Analyzer.calcManifest(Analyzer.java:694) at aQute.bnd.osgi.Builder.build(Builder.java:108) at org.apache.felix.bundleplugin.BundlePlugin.buildOSGiBundle(BundlePlugin.java:972) at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:467) at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:384) at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:375) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError
So i tried for the cause and solution of the above exception and added below lines inside parent pom.xml file of the project but still same issue
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<meminitial>512m</meminitial>
<maxmem>1048m</maxmem>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
then i added
MAVEN_OPTS="-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled"
inside the System variable section of Environment variable but this also not helping.I am using Windows 10 and Java version 8.
Can someone tell what will be solution ?
Solution 1:[1]
Adding these System variables will fix the issue
MAVEN_OPTS = -Xmx2048M -Xss128M -XX:MaxPermSize=2048M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC
This can be added in Environment variable.
Solution 2:[2]
For Windows, I solved the GC overhead limit exceeded
issue, by modifying the environment MAVEN_OPTS
variable value with:
-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Subodh Joshi |
Solution 2 | xKobalt |