Long running open connections badly leak memory
From: Joerg von Frantzius (joerg.von.frantzius_at_artnology.REMOVE.com)
Date: 02/18/05
- Next message: Alin Sinpalean: "Re: JDBC driver doesn't close socket event after connection.close()"
- Previous message: Phil Magill: "java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Unhandled token"
- Next in thread: Alin Sinpalean: "Re: Long running open connections badly leak memory"
- Reply: Alin Sinpalean: "Re: Long running open connections badly leak memory"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Feb 2005 13:36:21 +0100
Hi,
I wrote a batch import process that uses connection pooling, i.e. the
connections are never closed until the process is finished. I am writing
large chunks of data (byte[]) into the database, and I made absolutely
sure that my application does not hold any references to the byte[]
objects. However, the process increasingly consumes memory until an
OutOfMemoryError, and I tracked it down to the Microsoft JDBC driver
still holding references to the byte[] objects. The workaround is to
clear the pool "from time to time", closing its connections. When I do
that, the memory is properly reclaimed by the GC.
This "from time to time" involves some unsatisfying heuristics, though
(apart from the inconvenience of having to find the pool and access it).
If the driver is doing any caching on purpose, it should be documented
somewhere, and it should be configurable. My guess is that it's not on
purpose, though. I can't see much sense in holding on to written data
after a transaction is finished.
In case any driver developer should be interested, using a profiling
tool I found references from the following driver classes to a byte[]
object that should normally be reclaimed by the GC:
com.microsoft.jdbc.sqlserver.SQLServerPacketizingDataConsumer and
com.microsoft.jdbc.sqlserver.tds.TDSConnection
Regards,
Jörg.
- Next message: Alin Sinpalean: "Re: JDBC driver doesn't close socket event after connection.close()"
- Previous message: Phil Magill: "java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Unhandled token"
- Next in thread: Alin Sinpalean: "Re: Long running open connections badly leak memory"
- Reply: Alin Sinpalean: "Re: Long running open connections badly leak memory"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|