[C++-sig] Help with shared_ptr

Eric wstwej03 at sneakemail.com
Sun Jun 27 05:42:48 CEST 2004


Hello all,

I've managed to get myself stuck again, and could use some pointers in how
to debug my way out of this situation. I have to kinds of objects that are
wrapped in a boost::shared_ptr and returned to python. They are both
registered with python like this:

    boost::python::register_ptr_to_python< boost::shared_ptr<ClassOne> >();
    boost::python::register_ptr_to_python< boost::shared_ptr<ClassTwo> >();

the strange thing is that the release function of ClassOne is called when
python loses all references to it, but ClassTwo's is never called. From
within python I have managed to ensure that ClassTwo is actually being
released, by using weakref as follows:

# win is my ClassTwo object
wr = weakref.ref(win)
assert wr()
del win
sys.exc_clear()
gc.collect()
assert not wr()


So now I am trying to debug this situation. Any help or suggestions are
greatly appreciated.

Thank you,

Eric





More information about the Cplusplus-sig mailing list