[英]PermGen space with jetty
I'm developing a java web application where I'm using mavenlike tool of project managment. 我正在开发一个java web应用程序,我正在使用mavenlike项目管理工具。 Now my trouble is that if i setted jetty for autoscan each 20 second in this way:
现在我的麻烦是,如果我用这种方式每20秒设置一次自动扫描码头:
<!-- To launch embded jetty server -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven-jetty-plugin.version}</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${project.name}</contextPath>
<extraClasspath>target/classes;../services/target/classes;</extraClasspath>
</webAppConfig>
<scanTargets>
<scanTarget>target/classes</scanTarget>
<scanTarget>../services/target/classes</scanTarget>
</scanTargets>
</configuration>
</plugin>
Jetty starts in a correct way in fact i get: Jetty以正确的方式开始实际上我得到:
[INFO] Started Jetty Server
[INFO]启动了Jetty Server
[INFO] Starting scanner at interval of 20 seconds.
[INFO]以20秒的间隔启动扫描仪。
But at the first scan i get the following error: 但在第一次扫描时,我收到以下错误:
ERROR ContextLoader - Context initialization failed
错误ContextLoader - 上下文初始化失败
java.lang.OutOfMemoryError: PermGen space
java.lang.OutOfMemoryError:PermGen空间
How can I do to fix it? 我该怎么做才能解决它?
Update 1 更新1
I try to increse a PermGen space from my Eclipse Ide in this way: 我尝试以这种方式从Eclipse Ide增加PermGen空间:
but after the first scan i get back the same error. 但在第一次扫描后我得到了同样的错误。
How can I do to fix it? 我该怎么做才能解决它?
Have you tried running under JDK8? 你试过在JDK8下运行吗? PermGen has been replaced with MetaSpace and might fix your PermGen issues: http://www.infoq.com/news/2013/03/java-8-permgen-metaspace
PermGen已被MetaSpace取代,可能会修复您的PermGen问题: http : //www.infoq.com/news/2013/03/java-8-permgen-metaspace
Jetty also has some documentation about preventing classloader leaks that might fill up permgen: http://www.eclipse.org/jetty/documentation/current/preventing-memory-leaks.html Jetty还有一些关于防止可能填满permgen的类加载器泄漏的文档: http : //www.eclipse.org/jetty/documentation/current/preventing-memory-leaks.html
Put this under the <configuration>
element: <jvmArgs>-XX:PermSize=256M -XX:MaxPermSize=512M</jvmArgs>
把它放在
<configuration>
元素下: <jvmArgs>-XX:PermSize=256M -XX:MaxPermSize=512M</jvmArgs>
So the Maven plugin will look like this: 所以Maven插件看起来像这样:
<!-- To launch embded jetty server -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven-jetty-plugin.version}</version>
<configuration>
<jvmArgs>-XX:PermSize=256M -XX:MaxPermSize=512M</jvmArgs>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${project.name}</contextPath>
<extraClasspath>target/classes;../services/target/classes;</extraClasspath>
</webAppConfig>
<scanTargets>
<scanTarget>target/classes</scanTarget>
<scanTarget>../services/target/classes</scanTarget>
</scanTargets>
</configuration>
</plugin>
NOTE: if it fails with a message that it can't allocate so much memory use lower numbers. 注意:如果失败并显示无法分配如此多内存的消息,请使用较低的数字。
尝试使用-XX增加MaxPermGen空间:MaxPermSize = 512m传递给MAVEN_OPTS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.