Hi,

I'm using Tomcat 7.0.11 and I'm experiencing a leak problem.
This is what I find in the log:

Jul 29, 2011 7:36:51 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesJdbc
SEVERE: The web application [/admin] registered the JDBC driver
[com.mysql.jdbc.Driver] but failed to unregister it when the web application
was stopped. To prevent a memory leak, the JDBC Driver has been forcibly
unregistered.
Jul 29, 2011 7:36:51 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/admin] appears to have started a thread named
[ParadiseManualzoneTimer] but has failed to stop it. This is very likely to
create a memory leak.
Jul 29, 2011 7:36:55 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/admin] is completed

Regarding the JDBC driver, I understand that the Tomcat mechanism to solve
the leaks is able to unregister it, so for now I want to concentrate in the
other leak, later I will get back to this and find the way to solve it.

Regarding the thread, it belongs to a java.util.Timer. It is a timer that I
create in the contextInitialized() method of my app, and I attach 3 tasks to
it (java.util.TimerTask). These tasks work great during the live of the app.
In the contextDestroyed() method I do this:


        //Cancel tasks
        LinkedList<java.util.TimerTask> tasks=
(java.util.LinkedList<java.util.TimerTask>)(contexto.getAttribute("TASKS"));
        Iterator<java.util.TimerTask> taskIterator =tasks.iterator();
        while (taskIterator.hasNext())
        {
            java.util.TimerTask task =taskIterator.next();
            task.cancel();
        }
        contexto.removeAttribute("TASKS");
        taskIterator=null;
        tasks=null;


        //Destroy Timer
        java.util.Timer
timer=(java.util.Timer)contexto.getAttribute("TIMER");
        contexto.removeAttribute("TIMER");
        timer.cancel();
        timer=null;

I think I'm doing the right thing, but it seems that the thread stays in the
JVM. Im using "Yourkit" (a very powerful profiler!) and I clearly see that
thread.
How do I solve it? Do I need to kill the thread somehow, or should it die as
soon as I cancel the timer with the timer.cancel() method?

Thanks in advace!

Reply via email to