Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:14:17+00:00 2026-05-24T00:14:17+00:00

I had discovered that using selectby method with sqlobject there are leak memory. For

  • 0

I had discovered that using selectby method with sqlobject there are leak memory.

For example, when I execute this 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()


for iteration in range(20):
    start = datetime.now()
    for 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 the 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 use connection.clear(), expire, etc but I get the same result.
For example, if I change 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:14:18+00:00Added an answer on May 24, 2026 at 12:14 am

    If you run the test with profile, for example
    python -m cProfile -s cumulative
    You can check that the problem is in the cursor of psycopg2.

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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently inherited some code that someone else had written. I discovered that everywhere
I had a discussion with some colleagues mentioning that there are not too many
I've just discovered that using <div /> instead of <div></div> completely destroys my page
I had been programming under the assumption that, when calling a method in C#
While experimenting with this question on collections in Spring.NET , I discovered that Spring
We had discovered strange behaviour of popups in IE8. In IE7 and IE6 our
Had a coworker ask me this, and in my brain befuddled state I didn't
Had a page that was working fine. Only change I made was to add
Had a good search here but can't see anything that gets my mind in
I had to delete all the rows from a log table that contained about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.