Analyzing Python GC output - what is a "cell", and what information is available about it.
nagle at animats.com
Fri Jan 11 18:20:12 CET 2008
Duncan Booth wrote:
> John Nagle <nagle at animats.com> wrote:
>> I'm printing out each entry in "gc.garbage" after a garbage collection in
>> DEBUG_LEAK mode, and I'm seeing many entries like
>> <cell at 0x00F7C170: function object at 0x00FDD6B0>
>> That's the output of "repr". Are "cell" objects created only from
>> external C libraries, or can regular Python code generate them? Is there
>> any way to find out what the 'function object' is from within Python?
> Cell objects are created whenever you have a function that references a
> variable in an outer scope. e.g.
> So in your case, cell.cell_contents.func_name might help.
except Exception, message:
<cell at 0x00F88DF0: function object at 0x0100CFB0>
Type: <type 'cell'>
Unprintable: 'cell' object has no attribute 'cell_contents'
So it doesn't have a "cell_contents" attribute.
'cell' object has no attribute 'dir'
'cell' object has no attribute '__dict__'
It looks like this is a low-level PyCellObject not generated from Python code.
Any ideas? I'm using the M2Crypto and MySQLdb libraries, and suspect
a reference count bug in one of those.
More information about the Python-list