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)