[C++-sig] Re: Re: Re: cPickle in extension module

Norbert Riedlin nr at netatec.de
Tue Jun 25 11:09:24 CEST 2002


> Date: Mon, 24 Jun 2002 07:47:13 -0700 (PDT)
> From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>
> Subject: Re: [C++-sig] Re: cPickle in extension module
> To: c++-sig at python.org
> Reply-To: c++-sig at python.org
>
>
> I remember a long while ago I also had a problem with memory leaks when
> returning PyObject*. This was "fixed" by returning a boost::python::ref
> instead. For example:
>
> boost::python::ref Loads(const std::string& theString) const {
>   return boost::python::ref(PyObject_CallFunction(m_loads, "s",
> theString.c_str()));
> }
>
> You might want to replace all your PyObject* by ref. That way you could
> eliminate all DECREF and the destructor of your pickle helper class.
>
> Ralf
>
Hi Ralf,

thank you for your help, now all memory leaks have vanished even in version
1.22. One last question: "... replace all your PyObject* by ref...."
excludes overloads of to_python, right? In my original code (not in the
example above) there are quite a few places I need the overloads.

Norbert
--
Norbert Riedlin
Tel.: +49 (0)7243-2176-24
Fax.: +49 (0)7243-2176-19
mailto:norbert.riedlin at netatec.de

netatec GmbH
Am Hardtwald 3
76275 Ettlingen







More information about the Cplusplus-sig mailing list