On Dec 7, 2007, at 1:17 AM, Arun Kumar PG wrote:
> I used weak ref dict and doing a session.clear() post every request. > But when I do a len(gc.get_objects()) post every request I can see > that the number of objects keeps on increasing. Do we have a > background thread that frees up the unused objects in SA after a > while? theres no threading code in sqlalchemy. the session lets go of things that are no longer referenced and especially if youre saying session.clear() it unconditionally clears everything. if youd like to ensure that your session is empty, just call len(list(session)). make sure youre not doing anything like new creating classes and mappers on the fly, mappers are stored in a registry (this registry should be self-cleaning also on the next release). Also, if your application uses multiple threads, and you are using a thread local storage object such as the scoped_session(), if the threading model is such that brand new threads are spawned for every request instead of reusing existing threads from a thread pool, that you call Session.remove() at the end of the thread's lifecycle. Otherwise that Session object will hang around in the thread local dict keyed to a thread id that doesn't exist anymore. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
