python - sqlobject: leak memory using selectby method -



python - sqlobject: leak memory using selectby method -

i had discovered using selectby method sqlobject there leak memory.

for example, when execute code:

connection = connectionforuri('postgresql://test:test@localhost/test_sql_object') tran = connection.transaction() sqlhub.threadconnection = tran class person(sqlobject): firstname = stringcol() middleinitial = stringcol(length=1, default=none) lastname = stringcol() iteration in range(20): start = datetime.now() key in range(1000): person = person.selectby(firstname='name%s%s' % (iteration,key)) if person: select = person[0] end = datetime.now() print "time ",iteration,':' , end - start

and result is

time 0 : 0:00:03.328198 time 1 : 0:00:03.382905 time 2 : 0:00:03.690991 time 3 : 0:00:04.436301 time 4 : 0:00:05.021656 time 5 : 0:00:05.393993 time 6 : 0:00:05.791572 time 7 : 0:00:06.151833 time 8 : 0:00:06.517327 time 9 : 0:00:06.779239 time 10 : 0:00:06.961454 time 11 : 0:00:06.872361 time 12 : 0:00:07.114973 time 13 : 0:00:07.473208 time 14 : 0:00:07.737618 time 15 : 0:00:07.951056 time 16 : 0:00:08.199360 time 17 : 0:00:08.600283 time 18 : 0:00:08.802639 time 19 : 0:00:09.131514s

i test utilize connection.clear(), expire, etc same result. example, if alter person class

class person(sqlobject): class sqlmeta: cachevalues = false firstname = stringcol() middleinitial = stringcol(length=1, default=none) lastname = stringcol()

the result is

time 0 : 0:00:03.298583 time 1 : 0:00:03.465153 time 2 : 0:00:03.955067 time 3 : 0:00:04.594931 time 4 : 0:00:05.062099 time 5 : 0:00:05.172968 time 6 : 0:00:06.011087 time 7 : 0:00:06.106087 time 8 : 0:00:06.475573 time 9 : 0:00:06.836605 time 10 : 0:00:06.963226 time 11 : 0:00:06.889263 time 12 : 0:00:07.219188 time 13 : 0:00:07.417601 time 14 : 0:00:07.737096 time 15 : 0:00:08.128259 time 16 : 0:00:08.217653 time 17 : 0:00:08.612468 time 18 : 0:00:08.800511 time 19 : 0:00:08.979550

thanks.

if run test profile, illustration python -m cprofile -s cumulative can check problem in cursor of psycopg2.

the solution in https://sourceforge.net/tracker/?func=detail&atid=540673&aid=3366899&group_id=74338

python memory-leaks sqlobject

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -