title: Cassandra Python driver error(Memory leak while creating sessions)
body: <p>I am changing the original post to memory leak, as what i have observed that cassandra python driver do not release sessions from memory. And during heavy inserts its eat up all the memory (Thus crashes cassandra as not enough room left for GC).</p>
  
  <p>This was raised earlier but i see the issue in latest drivers as well.</p>
  
  <p><a href="https://github.com/datastax/python-driver/pull/131" rel="nofollow">https://github.com/datastax/python-driver/pull/131</a></p>
  
  <pre><code>     In [2]: cassandra.__version__
       Out[2]: '2.1.4'
  
  class SimpleClient(object):
  session = None
  
  def connect(self, nodes):
      cluster = Cluster(nodes)
      metadata = cluster.metadata
      self.session = cluster.connect()
      logging.info('Connected to cluster: ' + metadata.cluster_name)
      for host in metadata.all_hosts():
          logging.info('Datacenter: %s; Host: %s; Rack: %s', host.datacenter, host.address, host.rack)
          print ("Datacenter: %s; Host: %s; Rack: %s"%(host.datacenter, host.address, host.rack))
  
  def close(self):
      self.session.cluster.shutdown()
      logging.info('Connection closed.')
  
  def main():
      logging.basicConfig()
      client = SimpleClient()
      client.connect(['127.0.0.1'])
      client.close()
  
  if __name__ == "__main__":
       count = 0
       while count != 1:
             main()
            time.sleep(1)
  </code></pre>
  
  <p>If any one have found the solution of it please share.</p>