简体   繁体   English

出现错误“ [junit] java.lang.OutOfMemoryError: PermGen space

[英]getting Error " [junit] java.lang.OutOfMemoryError: PermGen space

We are running Junits in linux server.我们在 linux 服务器上运行 Junits。 All of the sudden we started getting permGen space issue.突然间,我们开始遇到 permGen 空间问题。 Below are the parameters we are using to set space.下面是我们用来设置空间的参数。 Default value of max perm size is 174063616最大烫发大小的默认值为 174063616

ANT_OPTS=-Xmx4098m
export ANT_OPTS

JAVA_OPTS=-Xmx16392m
export JAVA_OPTS

After getting permgen space issue, I have changed the value of parameters as mentioned below.在得到 permgen 空间问题后,我更改了参数的值,如下所述。 But still no luck.但仍然没有运气。

ANT_OPTS=-Xmx4098m
export ANT_OPTS

JAVA_OPTS=-Xmx32784m
export JAVA_OPTS

If you have memory allocation errors related to the "permGen" space, it means you run with a Java 7 or inferior.如果您有与“permGen”空间相关的 memory 分配错误,这意味着您使用 Java 7 或更低版本运行。 So, as a side note, if you run a Java 8 or superior, you shouldn't see this error anymore since that space doesn't exist per se anymore and is only limited to the available native memory.因此,作为旁注,如果您运行 Java 8 或更高版本,则不应再看到此错误,因为该空间本身不再存在,并且仅限于可用的本机 memory。

The JVM option to manage the PermGen space is XX:MaxPermSize .用于管理 PermGen 空间的 JVM 选项是XX:MaxPermSize So you should add to the JVM with runs your unit tests this command line argument: -XX:MaxPermSize=256m .所以你应该添加到 JVM 并运行你的单元测试这个命令行参数: -XX:MaxPermSize=256m

The ANT_OPTS environement variable will configure the JVM used by Ant itself. ANT_OPTS变量将配置 Ant 本身使用的 JVM。 You should use this environement variable if the unit tests are not ran as forked.如果单元测试没有作为分叉运行,您应该使用这个环境变量。

If you run your unit tests in a JVM forked by Ant, then you should tell Ant to start the Junit task with some additionnal JVM arguments. If you run your unit tests in a JVM forked by Ant, then you should tell Ant to start the Junit task with some additionnal JVM arguments. The parameter you need to use is jvmarg .您需要使用的参数是jvmarg

See the official Ant documentation about the task: https://ant.apache.org/manual/Tasks/junit.html有关该任务,请参阅官方 Ant 文档: https://ant.apache.org/manual/Tasks/junit.CCD236E870D25

Thus, here is the piece of XML to set the proper property:因此,这是 XML 设置正确属性的部分:

<junit fork="yes">
    <jvmarg value="-XX:MaxPermSize=256m" />
</junit>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM