Major Memory Leak in PostgreSQL JDBC Driver

From: "Gerald Gutierrez" <gutz(at)kalador(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Major Memory Leak in PostgreSQL JDBC Driver
Date: 2001-04-10 22:39:06
Message-ID: IIEOKIIOJMELMIFMMEBFCECLCBAA.gutz@kalador.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


At least the 7.1 RC3 driver has a memory leak in that the
.../jdbc2/PreparedStatement.java class uses Java's ThreadLocal object for
"optimization" reasons. However, Sun's J2SE 1.3 leaks memory whenever this
class is used. Hence, repeated use of the JDBC driver's PreparedStatement
class will cause a major memory leak.

Our application running on the Orion application server using PostgreSQL
will crash with an OutOfMemoryError in less than an hour while stress
testing.

Our workaround is to disable the ThreadLocal object by patching the driver
before using it. The patch is simple and small; instead of using the
ThreadLocal object to retrieve a thread-local SimpleDateFormat instance so
that it doesn't have to be instantiated each time (this is the
optimization), just instantiate the SimpleDateFormat class each time. We've
noticed no performance loss and our application no longer has any memory
leaks.

Please consider fixing this problem before releasing 7.1.

Thanks.

Gerald.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-04-11 00:13:16 When I install postgresql using rpm it is ok. When I compile the fonts and execute the initdb hapen a Error: unknown type 'ame'.
Previous Message Gerald Gutierrez 2001-04-10 22:23:53 Major problem in PostgreSQL JDBC driver that will cause OutOfMemoryErrors