[ https://issues.apache.org/jira/browse/CASSANDRA-3244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13113452#comment-13113452 ]
Rick Shaw edited comment on CASSANDRA-3244 at 9/23/11 2:11 PM: --------------------------------------------------------------- Creating a {{Statement}} every time you need one is unnecessary but not illegal. The assumption is the {{Statement}} is closed when Spring is done, which should be just fine. The problem is the list in {{Connection}} _should_ be a list of open {{Statements}}. The implication being that closing a {{Statement}} removes itself from that list. Unfortunately this is not being done. The list is necessary. But it needs to be maintained by {{Statement}} because only it knows when it is asked to close. Thanks for catching this bug. I'll create a fix for this. was (Author: ardot): Creating a {{Statement}} every time you need one is unnecessary but not illegal. The assumption is the {{Statement}} is closed when Spring is done, which should be just fine. The problem is the list in {{Connection}} _should_ be a list of open {{Statements}}. The implication being that closing a {{Statement}} removes itself from that list. Unfortunately this is not being done. The list is necessary. But it needs to be maintained by {{Statement}} because only it knows when it is asked to close. As a note this has nothing to do with pooling. The JDBC driver pooling ({{PooledConnection}}) will handle the issues around {{Statement}} creation and does not engage the physical {{Connection}} so the connection can be reused because none of that state is placed at the physical level and is therefore reusable without closing it. Thanks for catching this bug. I'll create a fix for this. > JDBC CassandraConnection may lead to memory leak when used in a pool > -------------------------------------------------------------------- > > Key: CASSANDRA-3244 > URL: https://issues.apache.org/jira/browse/CASSANDRA-3244 > Project: Cassandra > Issue Type: Improvement > Components: Drivers > Affects Versions: 1.0.0 > Reporter: Patricio Echague > Priority: Minor > > I may be wrong here but I noticed that the implementations of > CassandraConnection#createStatement() and > CassandraConnection#prepareStatement() keep(cache) the created > Statement/PrepareStatement internally in a List. > They list is freed up only during CassandraConnection.close() which makes me > think that, if the connection object is used in a pool implementation, it > will lead to a memory leak as it will hold every single statement that is > used to interact with the DB until the connection gets closed. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira