Re: patch: add a finalizer to AbstractJdbc1Statement

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
Cc: "pgsql-jdbc (at) postgresql (dot) org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: patch: add a finalizer to AbstractJdbc1Statement
Date: 2003-08-18 11:11:22
Message-ID: 20030818111120.GB10329@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, Aug 18, 2003 at 11:38:22AM +0100, Paul Thomas wrote:
>
> On 17/08/2003 15:00 Oliver Jowett wrote:
> >This patch adds a finalizer to AbstractJdbc1Statement that closes the
> >statement. Without this, when server-side preparation is in use
> >statements
> >that are executed then discarded without an explicit close() will leak
> >resources on the backend while that connection remains open, as a
> >DEALLOCATE
> >never gets executed.
>
> Not a good solution IMHO. Relying on GC to clean up resource leaks is a
> poor solution.

I'm not suggesting that relying on GC for cleanup is a good idea. However,
without this patch, the driver will *always* leak backend resources with
longlived connections and leaky client code (which is possibly not under the
control of the eventual owner of the connection -- e.g. the appserver case).

> And it you simply System.exit() the JVM, GC is not called
> at all.

When the JVM exits, the physical connections go down so the backend will do
resource cleanup on its own.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message kevin 2003-08-18 14:02:39 Re: resultset.first() untrappable error
Previous Message Alexander V. Morokhovets 2003-08-18 10:45:07 Re: Strange executing batch