OSDN Git Service

Attached are patches for two fixes to reduce memory usage by the JDBC
authorBruce Momjian <bruce@momjian.us>
Thu, 28 Dec 2000 23:56:46 +0000 (23:56 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 28 Dec 2000 23:56:46 +0000 (23:56 +0000)
commit49740c5fb99094b3942d7b8588f545907fd17074
treee9aeaeff6c7d421a7f1e27e0f283a7bd8b175a35
parenta057cbec46753a40208b6755e7e4861b7c70343d
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.

Barry Lind
src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java