Re: Tomcat sessions memory usage and MySQL connections
Hi,
romanlutsk@gmail.com wrote:
I've checked the application, the database connections and resultSets
are closed everywhere, so there shouldn't be any memory leak in the app
itself.
Hmmm... so you mean something like that?:
Connection con=...
Statement stmt=...
ResultSet rs=...
....
rs.close();
stmt.close();
con.close();
Or do you really do it the following way?:
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try {
...
} finally {
if(rs!=null) {
rs.close();
}
if(stmt!=null) {
stmt.close();
}
if(conn!=null) {
conn.close();
}
}
You get waht I mean? If - in the first code-snippet - an exception is
thrown, the resources are *NOT* closed!
We have an application in which we store for every Connection where
(complete StackTrace!) it was created.
If the Connection is garbage collected and was not closed before, we can
log the Stacktrace and so see where the error is. I would suggest yout
to so the same!
Ciao,
Ingo