RE: finalize in LargeObject

From: Philip Crotwell <crotwell(at)seis(dot)sc(dot)edu>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: RE: finalize in LargeObject
Date: 2001-05-16 13:11:30
Message-ID: Pine.GSO.4.10.10105160848110.2457-100000@tigger.seis.sc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


Hi

The reason I suggested that the finializer be there is that when you are
using large objects via blobs, there is no way to say "I am done with this
blob" and have its resources cleaned up. The only thing you can do is set
the reference to null and hope the garbage collector cleans up the blob
and closes the connection before the backend hits a resource limit on
number of open large objects. IMHO, this is really a deficiency in the
Blob definition from sun, but there isn't a whole lot we can do about
that. :(

My database uses a large number of "small" large objects for seismic data.
They are being added and accessed all the time. When I was using straight
blobs, I would occasionally get errors that made me think that the back
end had too many open large objects, even though I only had a reference to
one Blob. I can't remember the exact error message, sorry.

I am not sure if the finalize would have helped, but I can't see
how it would hurt. I solved the problem by switching to just getBytes
calls on the result set, which closes the large object internally, and the
errors went away.

An alternative would be to change from a "every blob has an open large
object" to some sort of blob manager that used a "pool" of open large
objects. Then old blobs that were not being used could have their large
object connections closed, but the manager could remember "where" they
were in case the were accessed again.

Perhaps someone familar with the large objects on the back end can comment
on whether my "too many open large objects" theory has any basis in fact.
In addition, this was back when I was using 7.0, so I don't know if there
are any differences with 7.1.

thanks,
Philip

On Wed, 16 May 2001, Dickson, John wrote:

> > From: Bruce Momjian [mailto:pgman(at)candle(dot)pha(dot)pa(dot)us]
> > > Shouldn't there be a
> > >
> > > protected void finalize() {
> > > close();
> > > }
> > >
> > > in LargeObject.java so that the db resources are released when it is
> > > garbage collected or am I missing something?
>
> Without knowing the implementation details, I'd at least say that you should
> never rely on finalizers being run to release resources - they're not event
> guaranteed to run at all, let alone within a reasonable time.
>
> Cheers ...................... JohnD
>
> ------------------------------------------------------------------------
> John Dickson - Java developer - PowerPlus Australia
> johnd(at)pplus(dot)com(dot)au Ph 07-3367 0533
> ------------------------------------------------------------------------
>
>
> NOTICE - The information in this e-mail and any attachments is confidential
> and is intended for the addressee only. Reading, copying, disclosure or use
> by anybody else is not authorised. The contents do not represent the opinion
> of PowerPlus or any of its affiliates except to the extent that it relates
> to their official business. If you are not the intended recipient, please
> delete this message and any attachments and advise the sender by return
> e-mail.
>
> Virus protection is in place at PowerPlus, however virus protection remains
> the responsibility of the recipient.
>
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Laurent Duperval 2001-05-16 13:59:01 Writing portable SQL code in Java
Previous Message George Koras 2001-05-16 07:22:49 Re: access from java does not work in an applet!