From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Pierre Le Mouëllic <pierre(dot)lemouellic(at)xgs-france(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Memory leak ? |
Date: | 2011-04-06 10:47:56 |
Message-ID: | BANLkTikwPnCgd=wgw+H-0NRddZTNN8mMTw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
The garbage collector should be collecting those, so I would guess the
driver is holding a reference internally to the result set.
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
2011/4/6 Pierre Le Mouëllic <pierre(dot)lemouellic(at)xgs-france(dot)com>:
> 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 ?
>
> Pierre LE MOUËLLIC
>
> pierre(dot)lemouellic(at)xgs-france(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2011-04-06 10:50:12 | Re: Memory leak ? |
Previous Message | Mikko Tiihonen | 2011-04-06 10:30:18 | Re: Memory leak ? |