Catalina.out内存泄漏错误 [英] Catalina.out Memory leak error

查看:359
本文介绍了Catalina.out内存泄漏错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然在 tomcat / logs / catalina.out 中看到此错误。

I still see this error in tomcat/logs/catalina.out.

Dec 29, 2011 4:04:36 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/LoggingMonitor] appears to have started a thread named [Timer-1] but has failed to stop it. This is very likely to create a memory leak.
Dec 29, 2011 4:04:36 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8180

是否值得考虑,如果是,我该如何纠正?

Is it worth considering and if it is, how can I correct this?

推荐答案

这可能没什么大不了的(只要杀掉-9或其他东西)并且很容易修复。只需找出在/ LoggingMonitor上下文中运行的webapp然后grep其代码库...

This is probably no big deal (just kill -9 or something) and easy enough to fix. Just figure out which webapp in running on a context of /LoggingMonitor then grep its codebase for...

new Timer();

...并将它们全部替换为......

...and replace them all with...

new Timer( true );

java.util.Timer默认情况下不在守护程序线程中运行。您需要Web应用程序中的任何计时器在守护程序线程上运行(否则容器无法正常关闭,因为它正在等待Timer线程结束,它从未执行过)。找到所有新的Timer()调用,并用new Timer(true)替换它们,并且记录投诉应该停止。

java.util.Timer by default does not run in daemon threads. You need any Timers in your webapps to run on daemon threads (otherwise the container is unable to shutdown properly as it is waiting for the Timer thread to end, which it never does). Find all the "new Timer()" calls and replace them with "new Timer( true )" and the logging complaint should stop.

花一些时间学习JavaDocs关于守护进程与非守护进程的内容线程: http:/ /docs.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html

Spend some time in the JavaDocs learn something about daemon vs non daemon Threads: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html

当我在webapps工作时,如果我最终做了自己的多线程,我总是使用守护进程线程。使用java.util.concurrent中的工具,这变得非常罕见(必须做我自己的线程化的东西)。

When I'm working in webapps, I always use daemon threads if I end up doing any of my own multithreading. With the facilities in java.util.concurrent, this is becoming very rare (having to do my own Threading stuff).

最后,为了记录,我讨厌java .util.Timer并始终建议使用ScheduledExecutor之类的东西来执行定期的重复性任务。它很容易搞砸Timer并取出它在守护进程或其他方面执行的Tread。

Finally, and for the record, I hate java.util.Timer and always recommend using something like ScheduledExecutor to do periodic, repetitive tasks. Its too easy to screw up in Timer and take out the Tread it executes on, daemon or otherwise.

这篇关于Catalina.out内存泄漏错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆