Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 364FB1337BD0 for ; Wed, 6 Apr 2011 07:18:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 19239-09 for ; Wed, 6 Apr 2011 10:18:43 +0000 (UTC) X-Greylist: delayed 00:06:28.970854 by SQLgrey-1.7.6 Received: from mail.xgs-france.com (mail.xgs-france.com [194.110.245.5]) by mail.postgresql.org (Postfix) with ESMTP id 999AF1337B9C for ; Wed, 6 Apr 2011 07:18:41 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.xgs-france.com (Postfix) with ESMTP id 8921CACACA42 for ; Wed, 6 Apr 2011 12:18:41 +0200 (CEST) Received: from mail.xgs-france.com ([127.0.0.1]) by localhost (imap2.svcs.dc1.xgs-france.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cQWkDAJwA4Tk for ; Wed, 6 Apr 2011 12:18:41 +0200 (CEST) Received: from [10.11.1.101] (unknown [10.11.1.101]) by mail.xgs-france.com (Postfix) with ESMTP id 64D41ACACA3B for ; Wed, 6 Apr 2011 12:18:41 +0200 (CEST) Message-ID: <4D9C3E01.9030403@xgs-france.com> Date: Wed, 06 Apr 2011 12:18:41 +0200 From: =?ISO-8859-1?Q?Pierre_Le_Mou=EBllic?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Memory leak ? Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.186 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.723, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/28 X-Sequence-Number: 21754 With this code :
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 (SQLException e) {
                }
                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("select f_transite(?,'FPL','225',9,'test','','')");
    }

    public static void rollBack()
    {
        try
        {
            connDB.rollback();
        }
        catch(SQLException ex)
        {
        }
    }
}
In eclipse Helios profiler, Jdbc3ResultSet live instances increase (and never decrease). Same thing with org.postgresql.core.v3.QueryExecutorImpl$ErrorTrackingResultHandler and org.postgresql.core.v3.QueryExecutorImpl$1 classes.

f_transite stored procedure make some select, insert and update. If you need more explanation, i can give it to you.

Java 6
postgresql-9.0-801.jdbc3.jar
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)

Is it a memory leak ? Or my java code is wrong ?