title: Maven build failed with GC overhead limit exceeded
body: <p>I am trying to build the project with the following command </p>
  
  <pre><code>mvn clean install 
  </code></pre>
  
  <p>But every-time its end with memory issue ,then i run same command with <code>-X</code> option and it end with follwoing detail error</p>
  
  <blockquote>
    <p>[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]
    <a href="http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError" rel="nofollow noreferrer">http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError</a></p>
  </blockquote>
  
  <p>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</p>
  
  <pre><code>&lt;project&gt;
    [...]
    &lt;build&gt;
      [...]
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.1&lt;/version&gt;
          &lt;configuration&gt;
            &lt;fork&gt;true&lt;/fork&gt;
            &lt;meminitial&gt;512m&lt;/meminitial&gt;
            &lt;maxmem&gt;1048m&lt;/maxmem&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
      [...]
    &lt;/build&gt;
    [...]
  &lt;/project&gt;
  </code></pre>
  
  <p>then i added </p>
  
  <pre><code>MAVEN_OPTS="-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled"
  </code></pre>
  
  <p>inside the System variable section of Environment variable but this also not helping.I am using Windows 10 and Java version 8.</p>
  
  <p>Can someone tell what will be solution ? </p>