如何解决“超出GC开销限制”使用maven jvmArg? [英] How to solve "GC overhead limit exceeded" using maven jvmArg?

查看:559
本文介绍了如何解决“超出GC开销限制”使用maven jvmArg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


线程main中的异常java.lang.OutOfMemoryError:GC开销限制已超过

我尝试从类包的maven pom.xml中增加jvmArg堆大小:



http://maven.apache.org/xsd/maven-4.0.0.xsd>
4.0.0

 < parent> 
(...)
< / parent>


< artifactId> (...)< / artifactId>
< name>(...)< / name>

<属性>
< javaOpts.Xmx> 4g< /javaOpts.Xmx><! - 可在命令行上用-DjavaOpts.Xmx = ... - >
<(...)。basedir> $ { project.basedir} / ..< /(...)。basedir>
< / properties>

< build>
< plugins>
<插件>
< groupId> net.alchim31.maven< / groupId>
< art ifactId>阶-行家-插件< / artifactId的>
<配置>
<启动器>
< launcher>
< id> MyClassName< / id>
< mainClass>(...)< / mainClass>
< jvmArgs>
< jvmArg> -Xmx $ {javaOpts.Xmx}< / jvmArg>
(...)

我尝试了最后引用的很多值:




  • < jvmArg> -Xmx512m {javaOpts.Xmx}< / jvmArg>

  • < jvmArg> -Xmx4096M {javaOpts.Xmx}< / jvmArg> li> ...

  • < jvmArg> -Xmx10000000000M {javaOpts.Xmx}< / jvmArg>



  • 但是对于他们所有人来说,我都有同样的错误。

    任何人都可以帮助我?
    观察:我从 IntelliJ IDEA 运行。

    解决方案

    Java 7



    这不是Maven问题,您需要为虚拟机提供更多内存。您可以通过环境变量执行此操作,Maven Launcher将在加载时自动选择这些设置,并使用它们来配置底层Java VM。



    简单的做法是:
    $ b $ p $ export $ MAVEN_OPTS = - Xmx1024M -Xss128M -XX:MaxPermSize = 1024M -XX:+ CMSClassUnloadingEnabled



    Windows:

    set MAVEN_OPTS = -Xmx1024M -Xss128M -XX:MaxPermSize = 1024M -XX:+ CMSClassUnloadingEnabled



    (无双引号)

    Java 8

    Java 8已经用metaspace替换了永久代,并且新设置如下所示: p>

    export MAVEN_OPTS = - Xmx1024M -Xss128M -XX:MetaspaceSize = 512M -XX:MaxMetaspaceSize = 1024M -XX:+ CMSClassUnloadingEnabled


    When running a class I have the following exception:

    Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded

    I've tried to increase the jvmArg heap size from inside maven pom.xml of the class package:

    http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

    <parent>
        (...)
    </parent>
    
    
    <artifactId>(...)</artifactId>
    <name>(...)</name>
    
    <properties>
        <javaOpts.Xmx>4g</javaOpts.Xmx> <!-- default that can be adjusted on the command line with -DjavaOpts.Xmx=... -->
        <(...).basedir>${project.basedir}/..</(...).basedir>
    </properties>
    
    <build>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <configuration>
                    <launchers>
                        <launcher>
                            <id>MyClassName</id>
                            <mainClass>(...)</mainClass>
                            <jvmArgs>
                                <jvmArg>-Xmx${javaOpts.Xmx}</jvmArg>
                            (...) 
    

    I've tried the last cited line with many values:

    • <jvmArg>-Xmx512m{javaOpts.Xmx}</jvmArg>
    • <jvmArg>-Xmx4096M{javaOpts.Xmx}</jvmArg>
    • ...
    • <jvmArg>-Xmx10000000000M{javaOpts.Xmx}</jvmArg>

    But for all of them I have the same error.

    Anyone can help me? Observation: I'm running from IntelliJ IDEA.

    解决方案

    Java 7

    It's not a Maven issue, you need to give more memory to the VM. You do this via environment variables, and the Maven Launcher will automatically pick up these settings on load, and use them to configure the underlying Java VM.

    The simple way to do it is to:

    export MAVEN_OPTS="-Xmx1024M -Xss128M -XX:MaxPermSize=1024M -XX:+CMSClassUnloadingEnabled"

    Windows:

    set MAVEN_OPTS=-Xmx1024M -Xss128M -XX:MaxPermSize=1024M -XX:+CMSClassUnloadingEnabled

    (No double quotes)

    Java 8

    Java 8 has replaced permanent generation with metaspace, and the new settings look like this:

    export MAVEN_OPTS="-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled"

    这篇关于如何解决“超出GC开销限制”使用maven jvmArg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆