Re: Long running open connections badly leak memory
From: Alin Sinpalean (alin_at_earthling.net)
Date: 02/19/05
- Next message: Alin Sinpalean: "Re: java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Unhandled token"
- Previous message: Alin Sinpalean: "Re: JDBC driver doesn't close socket event after connection.close()"
- In reply to: Joerg von Frantzius: "Long running open connections badly leak memory"
- Next in thread: Joerg von Frantzius: "Re: Long running open connections badly leak memory"
- Reply: Joerg von Frantzius: "Re: Long running open connections badly leak memory"
- Messages sorted by: [ date ] [ thread ]
Date: 19 Feb 2005 10:39:04 -0800
Joerg von Frantzius wrote:
> 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
The MS driver does indeed do a lot of unnecessary caching (such as
caching the whole ResultSet in direct mode), but I don't think this is
your problem here.
You are closing all JDBC resources (i.e. connections, statements and
result sets), aren't you? Even if SQLExceptions are thrown...
Alin,
The jTDS Project.
- Next message: Alin Sinpalean: "Re: java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Unhandled token"
- Previous message: Alin Sinpalean: "Re: JDBC driver doesn't close socket event after connection.close()"
- In reply to: Joerg von Frantzius: "Long running open connections badly leak memory"
- Next in thread: Joerg von Frantzius: "Re: Long running open connections badly leak memory"
- Reply: Joerg von Frantzius: "Re: Long running open connections badly leak memory"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|