Hi,

inspecting the gc I see a sqlalchemy memory leak in my application,
here is the output from the gc:

<class 'sqlalchemy.engine.base.Connection'>: 2 -> 3 (+1)
<class 'sqlalchemy.engine.base.RootTransaction'>: 2 -> 3 (+1)
<class 'sqlalchemy.util.LRUCache'>: 1 -> 2 (+1)
<class 'sqlalchemy.util.PopulateDict'>: 2 -> 3 (+1)
<type 'tuple'>: 5987 -> 5990 (+3)
<class 'sqlalchemy.sql.expression._BindParamClause'>: 73 -> 80 (+7)
<type 'dict'>: 8943 -> 8954 (+11)
<class 'sqlalchemy.sql.expression.Insert'>: 1 -> 2 (+1)
<class 'sqlalchemy.util.OrderedDict'>: 180 -> 181 (+1)
<type 'instancemethod'>: 490 -> 487 (-3)
<class 'sqlalchemy.dialects.sqlite.base.SQLiteCompiler'>: 2 -> 3 (+1)
<type 'collections.defaultdict'>: 34 -> 35 (+1)
<type 'weakref'>: 3830 -> 3831 (+1)
<type 'list'>: 2953 -> 2963 (+10)

every time I make some database object a reference is added to
sqlalchemy objects and never released. I'm sure the problem is my
application and not sa, however I would like to know how to force
sqlalchemy to delete objects references.

I'm using these function to query gc:

def gcHistogram(self):
                import gc
                result = {}
                for o in gc.get_objects():
                        t = type(o)
                        count = result.get(t, 0)
                        result[t] = count + 1
                print len(result)
                return result

        def diffHists(self,h1, h2):
                for k in h1:
                        if k in h2:
                                if h1[k] != h2[k]:
                                        print "%s: %d -> %d (%s%d)" % (
                                                        k, h1[k], h2[k], h2[k] 
> h1[k] and "+" or "", h2[k] - h1[k])

thanks
Nicola

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to