If true, Tomcat attempts to null out any static or final fields from loaded classes when a web application is stopped as a work around for apparent garbage collection bugs and application coding errors.
There have been some issues reported with log4j when this option is true.
Applications without memory leaks using recent JVMs should operate correctly with this option set to false.
If not specified, the default value of true will be used.
public class LogThread extends Thread {
private static volatile boolean stopped;
private final StatisticsLogger statsLogger;
public LogThread(String loggerName, Config config) {
statsLogger = new FileLogger(loggerName, config);
}
public void run() {
while(!LogThread.stopped) {
try {
//do something
} catch (Exception ex) {
logger.error("Exception when logging data", ex);
}
}
statsLogger.shutdown();
}
public static final void shutdown() {
stopped = true;
}
}
Shutdown 在关闭中成为null,会抛出null point exception.
org.apache.catalina.loader. WebappClassLoader.ENABLE_CLEAR_REFERENCES
最新推荐文章于 2025-01-25 22:17:20 发布
本文探讨了Tomcat中如何通过调整配置来规避潜在的内存泄漏问题,特别是针对静态或final字段的处理,并讨论了这一设置对log4j的影响及在不同情况下的适用性。
7073

被折叠的 条评论
为什么被折叠?



