pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pierre Le Mouëllic <pierre.lemouellic@xgs-france.com>
To: pgsql-jdbc@postgresql.org
Subject: Memory leak ?
Date: Wed, 06 Apr 2011 12:11:58 +0200
Message-ID: <4D9C3C6E.8030502@xgs-france.com> (raw)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <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 (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+"&amp;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)
        {
        }
    }
}</pre>
    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.<br>
    <br>
    f_transite stored procedure make some select, insert and update. If
    you need more explanation, i can give 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 face="Arial" color="#000080"
        size="2"><b>Pierre LE MOU&Euml;LLIC<br>
        </b></font><font face="Arial" color="#000080" size="1"><br>
      </font>
      <a moz-do-not-send="true"
        href="mailto:pierre.lemouellic@xgs-france.com"><font
          color="blue" size="1"><u>pierre.lemouellic@xgs-france.com</u></font></a><br>
      <a moz-do-not-send="true"
        href="mailto:pierre.lemouellic@xgs-france.com"><font
          color="blue" size="1"><u></u></font></a>
    </div>
  </body>
</html>



view thread (10+ messages)  latest in thread

Message-ID: <4D9C3C6E.8030502@xgs-france.com>
Permalink:  ../4D9C3C6E.8030502@xgs-france.com/
Also on:    postgresql.org/message-id/4D9C3C6E.8030502@xgs-france.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pierre.lemouellic@xgs-france.com
  Subject: Re: Memory leak ?
  In-Reply-To: <4D9C3C6E.8030502@xgs-france.com>
  References: <4D9C3C6E.8030502@xgs-france.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox