Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#319 Memory Leak For DictCursor

MySQLdb-1.3
open
Andy Dustman
MySQLdb (285)
5
2012-09-19
2012-01-10
Anonymous
No

import MySQLdb as sql
import time

print "Creating connection to database"
connection = sql.connect(
host = HOST,
user = USER,
passwd = PASSWORD,
db = dbName)
### MEMORY LEAK ######
cursor = connection.cursor(sql.cursors.DictCursor) # this gets a dictionary cursor,

### NO MEMORY LEAK ###
#cursor = connection.cursor()

### MEMORY LEAK ######
#cursor = connection.cursor(sql.cursors.SSDictCursor) # this gets a server side dictionary cursor,

print "Executing query from Silly Table"
cursor.execute('''select * from sillytable''') # memory leak here

print "Releasing Resources"
cursor.close()
connection.close()
cursor=None
connection = None
gc.collect()
time.sleep(10)

Related

Bugs: #332

Discussion