项目使用文件来保存修改,为了方便直接把文件放在src目录下;部署后发现过了一阵tomcat就会宕机;
日志为:
Oct 18, 2013 5:20:11 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Oct 18, 2013 5:20:11 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/a7list] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@13c4a657]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@5384a3e4]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
...-----
tomcat 6.025以后引入了一种内存泄露的检查机制,会把不能垃圾收集的对像作日志。
当您从新部署您的应用程序时,Tomcat 将建立新的类加载器。旧类加载器必须是垃圾回收,不然你会 permgen 内存泄漏。
分析缘由是因为运行项目的classes目录文件变动引发tomcat reload,同时reload时没有释放资源引发的宕机。
修改方式:
一、部署时修改tomcat 的server.xml文件,让项目变动时不reload。
修改文件:conf\server.xml
修改位置:
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/myapp" docBase=" " debug="0" reloadable="false"/>
二、将变动文件放到项目代码外面。
采用的方式是两种都使用了~