Re: Memory leak in 8.0 JDBC driver?

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: Memory leak in 8.0 JDBC driver?
Дата
Msg-id 52EF20B2E3209443BC37736D00C3C1380422A8B3@EXADV1.host.magwien.gv.at
обсуждение исходный текст
Ответ на Memory leak in 8.0 JDBC driver?  ("Albe Laurenz" <all@adv.magwien.gv.at>)
Ответы Re: Memory leak in 8.0 JDBC driver?  (Dave Cramer <pg@fastcrypt.com>)
Re: Memory leak in 8.0 JDBC driver?  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
I think that I have found the memory leak, and it is indeed in the JDBC
driver.
All code references in the following refer to the 8.0-312 JDBC Source.

I have an org.postgresql.jdbc3.Jdbc3PreparedStatement containing
INSERT INTO PARENT (ID, NAME, NUMMER) VALUES (?, ?, ?)
I execute this statement thousands of times with different parameters.
After each execution I commit().
Some of these statements fail due to a constraint violation, then I
rollback().

Whenever this statement is executed *and fails*, execution reaches
org.postgresql.core.v3.QueryExecutorImpl.processResults(), line 1280
where an org.postgresql.util.PSQLWarning is retrieved with the contents:
LOG: statement: INSERT INTO PARENT (ID, NAME, NUMMER) VALUES ($1, $2,
$3)

The handler that handles the warning is the anonymous class in
org.postgresql.core.v3.QueryExecutorImpl.sendQueryPreamble(), line 381.

This in turn calls
org.postgresql.jdbc2.AbstractJdbc2Statement.StatementResultHandler.handl
eWarning(), line 191.

This causes the SQLWarning to be appended at the end of the warning
chain of
the prepared statement, as you can see in
org.postgresql.jdbc2.AbstractJdbc2Statement.addWarning(), line 546.

The problem is that the warning chain is never cleared. According to the
documentation of java.sql.Statement.getWarnings(),
'The warning chain is automatically cleared each time a statement is
(re)executed'
This obviously does not happen.

Indeed, when searching the source of the JDBC driver, I cannot find a
single reference
to the clearWarnings() method, nor is
org.postgresql.jdbc2.AbstractJdbc2Statement.warnings
ever reset directly.

The warnings chain grows endlessly and gobbles up the heap.

I guess I should file a bug report for this, right?

Yours,
Laurenz Albe

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Memory leak in 8.0 JDBC driver?
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: Memory leak in 8.0 JDBC driver?