AKI*_*WEB 53 java tomcat permgen
我在Windows环境中工作.每次我使用tomcat时都会收到此错误
Apr 30, 2012 5:30:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
2012-04-30 17:30:37.719 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@4ae53a99
2012-04-30 17:30:37.719 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to failure to connect to {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused: no further information
Apr 30, 2012 5:30:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
Exception in thread "Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}" java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:38 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:38 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:38 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:41 PM org.apache.catalina.connector.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request processing
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:43 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Throwable, location=/error.action]
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:42 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Throwable, location=/error.action]
java.lang.OutOfMemoryError: PermGen space
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen space
Run Code Online (Sandbox Code Playgroud)
我尝试添加JAVA_OPTS with the value as -Xms1024m -Xmx1024m系统变量,但我一次又一次地得到相同的错误(java.lang.OutOfMemoryError:PermGen空间).任何帮助将不胜感激.我也读过stackoverflow中的其他帖子,但它没有成功.
Mic*_*ael 107
PermGen空间是Tomcat用于存储类定义(仅限定义,没有实例化)和已实例化的字符串池的空间.根据经验,PermGen空间问题往往在开发环境中经常发生,因为Tomcat必须在每次部署WAR或执行jspc(编辑jsp文件时)时加载新类.就个人而言,当我进行开发测试时,我倾向于大量部署和重新部署战争,所以我知道我迟早会跑出去(主要是因为Java的GC周期仍然有点废话,所以如果你快速和频繁地重新部署你的战争足够的,空间填充的速度超过了他们的管理速度.
理论上,这应该不是生产环境中的问题,因为您(希望)不会在10分钟内更改代码库.如果它仍然发生,那只意味着你的代码库(和相应的库依赖项)对于默认的内存分配来说太大了,你只需要乱用堆栈和堆分配.我认为标准是这样的:
-XX:MaxPermSize=SIZE
Run Code Online (Sandbox Code Playgroud)
但是我发现最好的方法就是允许卸载类,这样你的PermGen永远不会用完:
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
Run Code Online (Sandbox Code Playgroud)
这样的东西在过去对我有用.有一点,在使用这些产品时会有显着的性能折衷,因为permgen扫描会对你提出的每个请求或类似的东西提出额外的2个请求.您需要平衡使用与权衡.
SRG*_*SRG 17
您必须为tomcat JVM的PermGenSpace分配更多空间.
这可以使用JVM参数完成:-XX:MaxPermSize = 128m
默认情况下,PermGen空间为64M(它包含所有已编译的类,因此如果类路径中有很多jar(类),则可能确实填充了此空间).
另外,您可以使用JVisualVM监视PermGen空间的大小,甚至可以使用YourKit Java Profiler检查其内容
Raf*_*ael 10
为了补充Michael的答案,根据这个答案,处理问题的一种安全方法是使用以下参数:
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+UseConcMarkSweepGC
Run Code Online (Sandbox Code Playgroud)
小智 5
如果tomcat作为Windows服务运行,则CATALINA_OPTS和JAVA_OPTS似乎都没有任何效果.
您需要在GUI中的Java选项中设置它.
以下链接解释得很好
http://www.12robots.com/index.cfm/2010/10/8/Giving-more-memory-to-the-Tomcat-Service-in-Windows
| 归档时间: |
|
| 查看次数: |
108928 次 |
| 最近记录: |