Memory leak ? - Mailing list pgsql-jdbc
From | Pierre Le Mouëllic |
---|---|
Subject | Memory leak ? |
Date | |
Msg-id | 4D9C3E01.9030403@xgs-france.com Whole thread Raw |
Responses |
Re: Memory leak ?
Re: Memory leak ? |
List | pgsql-jdbc |
<font face="Xerox Sans">With this code :<br /></font> <pre>public class TestJDBC { private static Timer timer; private static Connection connDB; private static PreparedStatement sQLStatement; public static void main(String[] args) throws SQLException, ClassNotFoundException { connexion("jdbc:postgresql://praslin.qual.dc1:5432/G01DPM", "postgres8", "password"); timer = new Timer(); timer.schedule(new local_task(), 1000L, 1000); } static class local_task extends TimerTask { public void run() { ResultSet rs=null; try { sQLStatement.setInt(1, 2602); rs = sQLStatement.executeQuery(); sQLStatement.setInt(1, 2604); rs = sQLStatement.executeQuery(); sQLStatement.setInt(1, 2605); rs = sQLStatement.executeQuery(); } catch (SQLException e) { } finally{ try { if(rs!=null) rs.close(); } catch (SQLExceptione) { } rollBack(); } } } public static void connexion(String chemin, String user, String password) throws SQLException, ClassNotFoundException { Class.forName("org.postgresql.Driver"); String url = chemin+"?user="+user+"&password="+password; // Connexion connDB = DriverManager.getConnection(url); connDB.setAutoCommit(false); initPreparedStatement(); } private static void initPreparedStatement() throws SQLException { sQLStatement = connDB.prepareStatement("selectf_transite(?,'FPL','225',9,'test','','')"); } public static void rollBack() { try { connDB.rollback(); } catch(SQLException ex) { } } }</pre> In eclipse Helios profiler, Jdbc3ResultSet live instances increase (and never decrease). Same thing with org.postgresql.core.v3.QueryExecutorImpl$ErrorTrackingResultHandlerand org.postgresql.core.v3.QueryExecutorImpl$1 classes.<br/><br /> f_transite stored procedure make some select, insert and update. If you need more explanation, i cangive it to you.<br /><br /> Java 6<br /> postgresql-9.0-801.jdbc3.jar<br /> PostgreSQL 8.2.5 on powerpc-apple-darwin8.8.0,compiled by GCC powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)<br/><br /> Is it a memory leak ? Or my java code is wrong ?<br /><br /><div class="moz-signature"><font color="#000080"face="Arial" size="2"><b>Pierre LE MOUËLLIC<br /></b></font><font color="#000080" face="Arial" size="1"><br/></font> <a href="mailto:pierre.lemouellic@xgs-france.com" moz-do-not-send="true"><font color="blue" size="1"><u>pierre.lemouellic@xgs-france.com</u></font></a><br/></div>
pgsql-jdbc by date: