近日开始关注JVM的问题,先用jstat -gcutil pid随意看了一套web系统的JVM情况(容器是tomcat 7,jdk是1.7),结果非常惊讶,Full GC频繁,且周期性出现。
问题出现了,好兴奋啊,搞定它我就能增长经验了哇!!于是乎,和我们亲爱的SA同事交流了一番,我用nohup jstat -gccause pid 1s >> ~/xxx/xxx.log &先把gccause日志记录下来,经过半天日志记录追踪之后,发现LGCC是System.gc()。很好奇怎么会出现这东西,我写的代码肯定没有System.gc(),有点怀疑是tomcat的问题(当时也只是怀疑,无任何根据的)。为了解决这个问题,我先尝试在JVM启动参数中加入-XX:+DisableExplicitGC来禁止System.gc(),大半天后再用jstat看gc情况,FGC的次数是0,然后问题解决了。
虽然问题临时解决了,为了知其然知其所以然,我继续深究了一番,最终找到了问题所在:是tomcat 7的一个默认配置(JreMemoryLeakPreventionListener)所导致的,更合适的解决方法似乎是 <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" gcDaemonProtection="false"/>。
以下是引用的内容,原文网址在:http://mail-archives.apache.org/mod_mbox/tomcat-users/201008.mbox/%3CAANLkTino=BjP5LsBCwncB2HvNDzyKLr5y-8yWdt15a89@mail.gmail.com%3E
Thank you Konstantin and Chris for your attention. As stated in the initial post: 'We have recently deployed tomcat-6.0.28 in our organization and are noticing every hour, a Full GC is occurring. The same application, same JVM, same JVM args, just a new tomcat release.' Using the default JreMemoryLeakPreventionListener configuration that has 'gcDaemonProtection=true' will result in 1hr FullGCs using Sun 1.6 b18, b20 and b21on Solaris and Windows. We've tested and successfully 'contained' the FullGC behavior using one of the below configurations: 1) suppress the FullGC using JVM arg -XX:+DisableExplicitGC 2) keep the FullGC but to defer to the CMS collector using JVM arg -XX:+ExplicitGCInvokesConcurrent 3) <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" gcDaemonProtection="false"/> 4) Disable the listener altogether We've decided to go with option 3.
相关推荐
tomcat GC 优化配置
对tomcat的gclog日志进行分析,进行可视化展示,可以查看一些配置参数,检查是否软件是否运行正常
包含tomcat7,tomcat8,tomcat9,解压、在eclipse配置好即可。
关于tomcat集群 部署 设置 优化 文档
[root@centos7 tomcat]# vim bin/catalina.sh 代码如下:JAVA_OPTS=’-Xms512m -Xmx4096m -XX:PermSize=64M -XX:MaxNewSize=128m -XX:MaxPermSize=64m -XX:ParallelGCThreads=8 -XX:+UseConcMarkSweepGC -Xloggc:/...
tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载
tomcat7_win64解压版tomcat7_win64解压版tomcat7_win64解压版
tomcat7 tomcat7 tomcat7 tomcat7 tomcat7 tomcat7 tomcat7
绿色版tomcat 7 无需安装,将war包扔进webapp中直接启动就可以。
tomcat7免安装版点击上传资源即表示您确认该资源不违反资源分享的使用条款,并且您拥有该资源的所有版权或者上传资源的授权
linux服务器64位的tomcat7下载,本人正在使用这个tomcat服务器,亲测有效
内含tomcat7 tomcat8 tomcat9免安装版本;供需要的人下载。
apache tomcat7 可以在window linux unix下运行的 !无毒,如果存在问题,请给我说! 用户名和密码都配置好了!
Tomcat7免安装版Tomcat7免安装版Tomcat7免安装版Tomcat7免安装版Tomcat7免安装版
针对tomcat7存在漏洞升级补丁,漏洞影响的tomcat7版本为Apache Tomcat 7.0.0 to 7.0.93
apache-tomcat-7.0.25 tomcat7
tomcat7(linux版本),亲试可以用。apache-tomcat-7.0.82.tar
tomcat工具包,包含tomcat7和tomcat8两个版本
tomcat 7 最新版本 apache-tomcat-7.0.109
用于java开发 tomcat 版本为:apache-tomcat-7.0.86