简体   繁体   English

OutOfMemoryError:启动嵌入式 Tomcat 时的 PermGen 空间

[英]OutOfMemoryError: PermGen space when starting an embedded Tomcat

I have a library ( vraptor-test ) that does unit testing at my webservices in my maven project.我有一个库( vraptor-test ),它在我的 Maven 项目中对我的 web 服务进行单元测试。 In onder to run these tests, this library starts an embedded Tomcat.为了运行这些测试,这个库启​​动了一个嵌入式 Tomcat。

Tomcat tomcat = new Tomcat();

I have checked the dependency tree, and the list below representss tomcat related jars added to my project by the test library:我检查了依赖树,下面的列表代表了测试库添加到我的项目中的tomcat相关jar:

+- org.apache.tomcat:tomcat-catalina:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-servlet-api:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-juli:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-annotations-api:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-api:jar:7.0.23:compile
[INFO] |  |  \- org.apache.tomcat:tomcat-util:jar:7.0.23:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.23:compile
[INFO] |  \- org.apache.tomcat:tomcat-jasper:jar:7.0.23:compile
[INFO] |     +- org.apache.tomcat:tomcat-jsp-api:jar:7.0.23:compile
[INFO] |     +- org.apache.tomcat:tomcat-el-api:jar:7.0.23:compile
[INFO] |     +- org.eclipse.jdt.core.compiler:ecj:jar:3.7:compile
[INFO] |     \- org.apache.tomcat:tomcat-jasper-el:jar:7.0.23:compile

When I run my test classes the error below pops up and the test doesn't even complete:当我运行我的测试类时,会弹出下面的错误并且测试甚至没有完成:

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space

Usually, I would make changes to setenv.bat under tomcat folder to increase the PermGem space, but, since I'm running an embedded Tomcat, I can't find its folder, only its jars.通常,我会更改 tomcat 文件夹下的setenv.bat以增加 PermGem 空间,但是,由于我运行的是嵌入式 Tomcat,我找不到它的文件夹,只能找到它的 jars。

I've tried increasing JVM memory in Eclipse (Window -> Preferences -> Java -> Installed JREs -> jdk -> Edit -> Default Vm Arguments) to -Xmx1024M -Xms1024M -XX:PermSize=2048m -XX:MaxPermSize=2048m but I'm still getting the same error.我尝试将 Eclipse 中的 JVM 内存(窗口 -> 首选项 -> Java -> 已安装的 JRE -> jdk -> 编辑 -> 默认 Vm 参数)增加到-Xmx1024M -Xms1024M -XX:PermSize=2048m -XX:MaxPermSize=2048m但我仍然遇到同样的错误。

Where can I change permgem space of my embedded tomcat?我在哪里可以更改嵌入式 tomcat 的永久空间?

Double-click on your Tomcat service under the Servers tab, and click on the "Open launch configuration" to open the Tomcat launch configuration window.在 Servers 选项卡下双击您的 Tomcat 服务,然后单击“打开启动配置”以打开 Tomcat 启动配置窗口。 Then, in their change your VM args (different from default VM args).然后,在他们更改您的 VM args(与默认 VM args 不同)。

EDIT: If you are running a JAR from a Junit Test, you will need to change the VM Arguments in the Junit Launch configruation.编辑:如果您从 Junit 测试运行 JAR,则需要更改 Junit Launch 配置中的 VM 参数。 You can view your Run/Debug launch configs and then edit the arguments tab.您可以查看运行/调试启动配置,然后编辑参数选项卡。

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

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