nattyddubbs
nattyddubbs

Reputation: 2095

Cassandra Bound Statements and Memory Leaking

I am using Cassandra prepared statements to execute my queries in a Scala application using the Datastax Cassandra Java driver.

We have conditional logic to check and see if a bound statement should execute based on some internal state of an object. Something to this effect:

def updateDatabase(x: String, y: String, z: String) = {
   val bound = statement.bind(x,y,x)     

   if(sequence_nr < current){
      session.execute(bound)
   }
}

Does this introduce a memory leak in either our Scala application or in Cassandra? My inclination is to say no but didn't want to make that assumption as I don't fully understand what the driver is doing behind the scenes with the bind call.

I appreciate the help.

Upvotes: 1

Views: 854

Answers (1)

adutra
adutra

Reputation: 4536

The bind() method generates a new instance of BoundStatement at each invocation, and session.execute() does not keep any reference to it, so it will be GC'ed. There is no risk of memory leaks here.

Upvotes: 3

Related Questions