Two minor fixes to reduce resource usage in JDBC drivers

From: Barry Lind <barry(at)xythos(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Two minor fixes to reduce resource usage in JDBC drivers
Date: 2000-12-26 20:44:30
Message-ID: 3A49032E.BBD063FF@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-patches

Attached are patches for two fixes to reduce memory usage by the JDBC
drivers.

The first fix fixes the PreparedStatement object to not allocate
unnecessary objects when converting native types to Stings. The old
code used the following format:
(new Integer(x)).toString()
whereas this can more efficiently be occompilshed by:
Integer.toString(x);
avoiding the unnecessary object creation.

The second fix is to release some resources on the close() of a
ResultSet. Currently the close() method on ResultSet is a noop. The
purpose of the close() method is to release resources when the ResultSet
is no longer needed. The fix is to free the tuples cached by the
ResultSet when it is closed (by clearing out the Vector object that
stores the tuples). This is important for my application, as I have a
cache of Statement objects that I reuse. Since the Statement object
maintains a reference to the ResultSet and the ResultSet kept references
to the old tuples, my cache was holding on to a lot of memory.

thanks,
--Barry

Attachment Content-Type Size
patch.diff text/plain 5.2 KB

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruce Momjian 2000-12-27 05:56:26 PHP and PostgreSQL
Previous Message Adam Lang 2000-12-26 13:44:29 Re: PG on a web-server...issues..and some general questions on PG deployment

Browse pgsql-patches by date

  From Date Subject
Next Message Brent Verner 2000-12-26 20:47:37 Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)
Previous Message Tom Lane 2000-12-26 19:41:33 Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)