[PyGreSQL] Memory leak, please help me see what I am doing wrong.

Ma Chenwei machenwei at gmail.com
Thu Feb 4 16:57:56 EST 2010


Hi Guys,

I have a few daemons written in python, which access a postgres
database constantly. As I was hunting for leaks I found what the way I
create and close the database connection is creating some leaks. I got
it down to a test loop to demonstrate the problem:

import pg
while 1:
        db = pg.connect(dbname='databasename',host=ip_address,port=port_number,user='username'
)
        db.close()
        del db

As this runs, the memory usage would keep increasing. Am I doing anything wrong?

I am running pg version 4.0, python version 2.5.4, Postgres version 8.4

Thank you very much!

Best Regards,

Chenwei


More information about the PyGreSQL mailing list