其他分享
首页 > 其他分享> > Tomcat抱怨线程未停止

Tomcat抱怨线程未停止

作者:互联网

我收到有关启动线程而不是结束线程或停止线程的异常信息. WebappClassLoader抱怨这些线程将导致内存泄漏.

这是怎么回事

>这样的线程是否有可能导致内存泄漏?还是可能?
>卡塔琳娜(Catalina)是否过于敏感?
>这甚至是有效的编程技术吗?

(管理Tomcat应用程序的这一方面对我来说是新手.但是,由于Web应用程序在高负载下数据库连接即将用尽时,我必须学习它,这需要解决.寻找内存泄漏是我们要做的许多事情之一正在调查.)

解决方法:

您可以在http://wiki.apache.org/tomcat/MemoryLeakProtection处了解Tomcat中棘手的内存泄漏问题(尤其是此警告),尤其是对于警告,您将看到:

If a webapp creates a thread, by default its context classloader is set to the one of the parent thread (the thread that created the new thread). In a webapp, this parent thread is one of tomcat worker threads, whose context classloader is set to the webapp classloader when it executes webapp code.

Furthermore, the spawned thread may be executing (or blocked in) some code that involves classes loaded by the webapp, thus preventing the webapp classloader from being collected.

So, if the spawned thread is not properly terminated when the application is stopped, the webapp classloader will leak because of the strong reference held by the spawned thread.

当您一次启动Web应用程序,然后将其拆解时,这种影响(以我的经验)是有限的.但是,在某些情况下,例如在连续集成方案中(CI服务器将应用程序的构建重复部署到未重新启动的Tomcat容器中),您可能会很快耗尽JVM中的内存.最终,这将在PermGen区域中将自身表现为OutOfMemoryException(假设您使用的是Sun / Oracle JVM).有关PermGen的更多详细信息,请参见http://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java

标签:tomcat,web-applications,java
来源: https://codeday.me/bug/20191202/2086927.html