[pygtk] PyGObject leaking?

Mario Beauchamp starged at gmail.com
Tue Apr 10 06:49:48 WST 2007


Hi all,

Suppose I have a barebone class "Dat" derived from gobject and I create an
extension module "gv" using h2def/codegen. There is nothing else in this class
(other than what is required) except for g_prints in the dispose
and finalize methods so I know when the objects are being freed.

In the generated code, the class seems correctly registered:

pygobject_register_class(d, "GvDat", GV_TYPE_DAT, &PyGvDat_Type,
                         Py_BuildValue("(O)", &PyGObject_Type));
pyg_set_object_has_new_constructor(GV_TYPE_DAT);

Now, if I run the following script,

from gv import Dat

def run():
    data = Dat()

if __name__ == '__main__':
    run()
    print 'exiting'

'exiting' is print before my 'dispose' and 'finalize' statements and not after
as I expected.

I thought that as soon as run() would return, data would go out of scope, its
Python ref count would drop to 0, the PyGObject would be freed and release the
underlying gobject which would be then disposed and finalized... all this
before the 'exiting' line.

Am I missing something here? Is my reasonning correct? Or is this a bug?

This is really an important matter for me since the real gv extension module is
required by both software packages I am developing (OpenEV and CIETmap). And
this is definitely a release stopper...

Thank you.

cheers
-- 
Mario B.
OpenEV home: http://openev.sourceforge.net


More information about the pygtk mailing list