Hi,
> 1) So far I didn't get a memory leak problem e.g. reported by
> profiler.
OK that's good to know.
> I only get these log warnings which hint that there is such
> a problem.
I guess the classloader of the web application stays in memory
unnecessarily for the first time you restart the web application. But
only the first time, and not after subsequent restarts. As wether the
solution I found really solves this problem I don't know - it might or
it might not. But I believe even if it wouldn't solve that problem,
it's not such a big deal. If it would consume more *each time* you
restart the web application - yes that would be a big problem. But I
don't think that ever was the case (even with older versions of H2).
> At this point anyone reading these logs can only assume
> that there is a memory leak.
Yes. The problem seems to be that the threads (that belong to the
database) directly refer to the classloader of the web app. This I can
solve. Whether or not the classloader of the web app can be unloaded
now I can't tell for sure however.
> 2) I occusionally end up (when shutting down Tomcat) with a
> "redirectServer.lock.db".
This is a bit strange. Tomcat should dispose the connection pool,
which in turn should close all connections to the database. That would
delete the .lock.db file. If it's not deleted, then at least one
database connection remains open during the Tomcat shutdown.
Is there a way to reproduce it? How to you stop Tomcat? (it should
work both with ./shutdown.sh and with Ctrl+C).
> This is also a problem for me since my app is part of an
> rpm installation and on uninstall due to existing
> redirectServer.lock.db the directories are not cleaned.
If the database is still open, you will be able to delete the .lock.db
file, but the file is re-created automatically after one second or so.
If you see this behavior, then the process is still alive. That would
mean you didn't actually stop the process.
> From what you are saying, your approach is to "mask" the warning?
I think not - I did what I read in the discussion at the Tomcat
mailing list. But I'm not completely sure it will in all cases have
the desired effect, as I don't fully understand how classloading works
within Tomcat.
> You are saying that there is no actually memory issue here?
I believe if there is a memory issue, it's just a one time problem
(the first restart of the web app might not release some of the
memory). But not a real memory leak (where memory usage grows and
grows after each restart). You could actually test it, you would need
to restart the web app in a loop (about 100 times or so) and check if
it ever runs out of memory.
> Because in my
> mind it seems to me that there is a subtle "race-condition" since H2
> expects all connections to be closed in order to shutdown properly,
> but it is Tomcat that decides when to close all the connections.
I wouldn't call this race condition. Yes, H2 expects all connections
to be closed, but not necessarily when the web app is stopped. The
connections should be closed when the connection pool is disposed,
which should occur at the latest when Tomcat is stopped.
Regards,
Thomas