help with memory leak

Neal Becker ndbecker2 at gmail.com
Tue May 27 15:56:43 EDT 2014


I'm trying to track down a memory leak in a fairly large code.  It uses a lot of 
numpy, and a bit of c++-wrapped code.  I don't yet know if the leak is purely 
python or is caused by the c++ modules.

At each iteration of the main loop, I call gc.collect()
If I then look at gc.garbage, it is empty.

I've tried using objgraph.  I don't know how to interpret the result.  I don't 
know if this is the main leakage, but I see that each iteration there are more
'Burst' objects.  If I look at backrefs to them using this code:

   for frame in count(1): ## main loop starts here
        gc.collect()
        objs = objgraph.by_type('Burst')
        print(objs)
        if len (objs) != 0:
            print(objs[0], gc.is_tracked (objs[0]))
            objgraph.show_backrefs(objs[0], max_depth=10, refcounts=True)

I will get a graph like that attached

A couple of strange things.

The refcounts (9) of the Burst object don't match the number of arrows into it.
There are 2 lists with 0 refs.  Why weren't they collected?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: objgraph-fCFPiC.png
Type: image/png
Size: 28804 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20140527/a5659af6/attachment.png>


More information about the Python-list mailing list