[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wekalist
Subject:    Re: [Wekalist] Memory leak using MySQL
From:       Peter Reutemann <fracpete () waikato ! ac ! nz>
Date:       2006-06-29 20:42:19
Message-ID: 44A43B2B.4040905 () waikato ! ac ! nz
[Download RAW message or body]

> First, thanks for some *very* useful software.  I found a memory leak 
> while using Weka's DatabaseSaver class in a Java program that transfers 
> data from an ARFF file to a MySQL database.  The leak occurred using 
> both the org.gjt.mm.mysql.Driver class and the com.mysql.jdbc.Driver 
> class.  The problem is actually in DatabaseConnection.java, in the 
> execute method, where m_PreparedStatement is never closed.
> 
> I've attached hacked copies of DatabaseSaver and DatabaseConnection, 
> with the package name changed.  In DatabaseConnection, I implemented an 
> executeUpdate method that uses PreparedStatement.executeUpdate() rather 
> than PreparedStatement.execute() for queries that will not return a 
> ResultSet.  (I thought it might be a tad more efficient.)  It explicitly 
> closes m_PreparedStatement to plug the leak.  I didn't modify the 
> execute method similarly, but I do recommend it.  The only change to 
> DatabaseSaver was to use the new executeUpdate method.

Thanks, will have a look at it sometime - what version of Weka is it 
based on?

AFAIK, according to the JDBC specifications a JDBC driver should release 
the memory it allocated as soon as the variables are out of scope. Well, 
so much about specs - MySQL doesn't seem to care much about it...

Cheers, Peter
-- 
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/     +64 (7) 838-4466 Ext. 5174

_______________________________________________
Wekalist mailing list
Wekalist@list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic