[Pyrex] __del__ not called on some objects
John (J5) Palmieri
johnp at redhat.com
Fri Aug 26 07:00:35 CEST 2005
You can find my simple test case at
http://people.redhat.com/johnp/files/pyrex_bug.tar.gz
tar xvfzp pyrex_bug.tar.gz
cd pyrex_bug
make
python test.py
It will show two objects being created with only one calling the __del__
handler. The failing object is declared as a cdef which is what causes
it to not call __del__ however simply deriving from it with a regular
class does call Test's __del__ method on object destruction.
It occurred to me that this might be intentional (however confusing)
since the cdef object it technically a c structure so I am not sure if
it is subject to the same life cycle as a python object though I don't
know why not since it acts just like one for the most part.
Anyway, there it is.
On Thu, 2005-08-25 at 20:37 -0700, Bob Ippolito wrote:
> On Aug 25, 2005, at 7:57 PM, John (J5) Palmieri wrote:
>
> > I just found a bug during my attempts to debug some memory leaks in
> > the
> > dbus bindings. We use __del__ to unref some C objects when the
> > wrapper
> > Pyrex object goes out of scope. The problem was our Message object
> > was
> > not calling __del__ and causing a huge memory leak. On further
> > inspection I noticed that other Message objects were. The difference
> > was the one calling __del__ were all subclasses of Message.
> > Subclassing
> > Message solved the problem though it seems dubious why this would
> > be the
> > case. It might have something to do with the fact that Message
> > exports
> > cdef methods while the derived classes only export the __init__
> > constructor.
> >
> > If you need any more information let me know.
>
> A simple reproducible example that demonstrates the problem would
> sure help.
>
> -bob
--
John (J5) Palmieri <johnp at redhat.com>
More information about the Pyrex
mailing list