| Bug #20003 | Connector kills Memory | ||
|---|---|---|---|
| Submitted: | 22 May 2006 16:48 | Modified: | 23 May 2006 12:30 |
| Reporter: | Theo Nietzschmann | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | mysql-connector-java-3.1.12-bin.jar | OS: | Windows (XP) |
| Assigned to: | CPU Architecture: | Any | |
[22 May 2006 17:19]
Mark Matthews
Where do you close your statements and result sets? If you don't do this explicitly, they will be closed for you when the "parent" object that created them is closed (as per the JDBC spec). Earlier versions of the driver didn't maintain references to these open statements and result sets (as is required by the JDBC spec), so they would be eligible for GC as soon as your application was done with them. The latest versions of the driver _are_ required to maintain these references, and will appear to leak memory for applications that do not follow the requirement in the JDBC spec that applications are responsible for calling _close()_ on resources they no longer are using. Are you sure that you actually call .close() on all result set and statement instances? Does adding "dontTrackOpenResources=true" to your JDBC URL configuration properties change the problem you see? If so, your application is "leaking" either result sets or statements, which is something you need to fix.
[22 May 2006 17:49]
Theo Nietzschmann
thx for quick reply you are right, ResultSet.close() will fix.

Description: mysql-connector-java-3.1.12-bin.jar don't free memory several calls to readListe() below cost more and more memory this results in a OutOfMemory Error for the java VM Sourcefragment: private void readListe(String query, int offset, int limit) { if(limit > 200) return; ResultSet rslt = null; StringBuffer statement = new StringBuffer(); statement.append("select * from messwert "); if(query != null) statement.append(query).append(" "); rslt = db.statement(statement.toString()); int i = 0; if(rslt != null) { try { if(offset != 0) rslt.absolute(offset); while( rslt.next() ) { Messwert messwert = new Messwert(); setMesswert(messwert, rslt); liste.addMesswert(messwert); i++; if(i>=limit) break; } } catch (SQLException e) { } } How to repeat: theo.nietzschmann@onlinehome.de Suggested fix: open and close connection at every request ;/ or use mm.mysql-2.0.4-bin.jar mysql-connector-java-5.0.0-beta-bin.jar dont fix