Re: Web App Redeploy Memory Leak

"sks" <[email protected]> Tue, 30 May 2006 09:20:52 +0100
Newsgroups gmane.text.xml.resin.user
Message-ID <00ca01c683c1$f845f960$0200a8c0@sks1>
I should also add I have tried making the context and datasource non static 
and looking them up each time (slower I know but just to make sure) and it 
makes no difference.

> Some of you may remember my on-going memory leak problem when re-deploying
> my web app.
>
> Scott said it might have been related to a JVM bug regarding primitive
> arrays and JVMTI but this bug has now been fixed in 1.5.07 and still it 
> was
> happening.
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5093520
>
> I have found the source of the bug anyway and it is in Resin (or I suppose 
> Java's) DataSource code.
>
> All my entity classes in my application extend from this base class
>
> public class ConnectionBase {
>
>    static Context ic;
>    static DataSource ds;
>
>    static {
>        try {
>            ic = new InitialContext();
>            ds = (DataSource) ic.lookup("java:comp/env/jdbc/mysql");
>        } catch (NamingException e) {
>            throw new RuntimeException("Error getting database DataSource", 
> e);
>        }
>    }
>
>    protected static Connection getConnection() throws SQLException {
>        return ds.getConnection();
>    }
> }
>
> I call getConnection obviously to get a connection.
>
> Now if I remove the DataSource code and instead use a 
> java.sql.DriverManager lookup each time it works perfectly and all objects 
> are garbage collected. I have not had to start Resin for 3 days on my 
> development machine (when its normally every hour or so).
>
>
>
>
>