如何彻底解决linux tomcat包错: java.lang.OutOfMemoryError: Java heap space ?

wangxi得 发布于 2014/08/21 14:10
阅读 3K+
收藏 0

具体报错log:

 Exception in thread "http-bio-8080-exec-691" java.lang.OutOfMemoryError: Java heap space at java.util.jar.JarFile.getBytes(JarFile.java:360) at java.util.jar.JarFile.initializeVerifier(JarFile.java:319) at java.util.jar.JarFile.getInputStream(JarFile.java:388) at org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:3063) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2824) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage( MessageSenderInterceptor.java:64) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:7 7) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:97) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:458) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:185) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:148) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.j ava:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

问题是:1.如果修改tomcat下配置文件catalina.sh添加

Linux下修改JVM内存大小:
要添加在tomcat 的bin 下catalina.sh 里,位置cygwin=false前 。注意引号要带上,红色的为新添加的.
# OS specific support. $var _must_ be set to either true or false.
JAVA_OPTS="-Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m"
cygwin=false
以上能否解决根本问题。(一般设置参数多少为好)

2.有没有其他方案?



加载中
0
JqbR001
JqbR001
dump出来分析,需要改程序还是进行jvm调优。
0
Feng_Yu
Feng_Yu

先尝试增加JVM内存,还是频繁OOM就找开发,监控一下程序性能,是否有程序的BUG导致内存一直不能释放。

最后罗嗦一下,不要直接改catalina.sh,我不知道你有没有读过catalina.sh,有没有注意到catalina.sh的注释部分有这样的一段话:

#   Do not set the variables in this script. Instead put them into a script
#   setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
wangxi得
wangxi得
好的 谢谢
0
sxgkwei
sxgkwei

内存不足啊,先该tomcat,把内存给到能给出的最大设置。

如果还是老这样,就去找程序猿麻烦,肯定是哪个坑爹的写了些坑爹的代码在里面。

返回顶部
顶部