[PyQt] SIP: memory leak in mapped type?

Giovanni Bajo rasky at develer.com
Sat Jul 28 16:36:02 BST 2007

On sab, 2007-07-28 at 12:30 +0100, Phil Thompson wrote:

> > - bug.h / bug.cpp is the source code, with two functions with identical
> > semantic but different signature.
> > - bug.sip is the trivial wrapper for both functions.
> > - stl.sip is the file with the mapped types for std::vector [notice that
> > most of it should be builtin in SIP in my humble opinion, but this is a
> > discussion for another day].
> > - bug.py triggers the memory leak. You can choose which function to test
> > in it. Both of them cause the leak.
> >
> > To compile, "setup.py build_ext --inplace".
> There is a SIP bug (fixed in tonight's snapshot) which affects mapped types 
> with the /Out/ annotation - but it has nothing to do with object ownership.

Then, I have not understood where my code is buggy and how I should fix
the memory leak.

I believe you are suggesting to add a /Transfer/ annotation in the SIP
file, but it is very unfriendly to stl.sip's users because they have to
remember it every time or they get a memory leak. Moreover, the vector
is returned *by value*, which really can't mean anything else but "give
ownership to Python".
Giovanni Bajo

More information about the PyQt mailing list