Hi Folks -

I'm a bit confused about how SQLObject works with caching. I'm trying to load some initial objects into a system and watch the memory usage of the process climb and climb. From what I've been able to discover so far, it seems to do with SQLObject caching the objects as they're created. Here's a sample program that loads 500,000 simple objects into a database:

# start of program
from sqlobject import *

sqlhub.processConnection = connectionForURI('sqlite:/tmp/fill.sqlobject')

class FillEntry(SQLObject):
    name  = StringCol()
    count = IntCol()

FillEntry.createTable()

trans = sqlhub.processConnection.transaction()
sqlhub.processConnection.autoCommit = False
#sqlhub.processConnection.debug      = True

for count in range(500000):
    fe = FillEntry(name = 'hello my name is %d' % count, count = count)
    if count % 1000 == 0:
        print count
        trans.commit()

trans.commit()
# end of program


Running shows memory using continuing to climb. If I change the class definition to:


class FillEntry(SQLObject):
    class sqlmeta:
        cacheValues = False
    name  = StringCol()
    count = IntCol()


I don't see any change, running the program continues to consume memory as more FillEntry objects are created. With the cacheValues being set to false, I expected that SQLObject would drop the objects after they've been written into the database. (It's entirely possible that I don't understand cacheValues or I'm using it wrong.)

The next thing that I tried was to remove the sqlmeta class and add a call to expire the FillEntry. So the loop becomes:

for count in range(500000):
    fe = FillEntry(name = 'hello my name is %d' % count, count = count)
    fe.expire()
    if count % 1000 == 0:
        print count
        trans.commit()


And that change resulted in memory usage remaining pretty flat throughout the program running.

Perhaps I'm using SQLObject incorrectly. Perhaps there's a bug in the code. Perhaps something else is going on. Could someone with a wee bit more knowledge and understanding of SQLObject provide some guidance as to how caching is supposed to work and how it can be controlled programatically?

Thanks!

- Peter