Memory leak due to JRuby runtime  not unregsitering JDBC drivers
----------------------------------------------------------------

                 Key: JRUBY-4226
                 URL: http://jira.codehaus.org/browse/JRUBY-4226
             Project: JRuby
          Issue Type: Bug
          Components: Embedding
    Affects Versions: JRuby 1.4
         Environment: JRuby 1.4.0, glassfish v3
            Reporter: Vivek Pandey
         Attachments: jruby-jdbc-leak.png

I am investigating memory leak related to hot deployment of Rails application 
on GlassFish. One of the hanging references is the JDBC driver, in this case: 
org.sqlite.JDBC. The class loader is org.jruby.util.JRubyClassLoader.

I tried to fix it by trying to do something like this:

            for (Enumeration e = DriverManager.getDrivers(); 
e.hasMoreElements();) {
                Driver driver = (Driver) e.nextElement();
                if (driver.getClass().getClassLoader() == 
getClass().getClassLoader()) {
                    DriverManager.deregisterDriver(driver);
                }
            }

This does not work because DriverManager.getDrivers() returns only the drivers 
loaded by this classloader so org.sqlite3.JDBC is not even reported although in 
the debugger I can see it very well and its loaded by JRubyClassLoader. So 
AFAIK I can't underegister the JDBC drivers loaded by jruby for a given rails 
application.

So the right fix will be in Ruby.tearDown() to do what I am trying to do using 
JRubyClassLoader loaded class. So basically, Ruby.tearDown() should 
deregister/unregister JDBC drivers

See the attached image of the heap dump analyzed using eclipse mem analyzer.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to