[PyQt] SIP: memory leak in mapped type?

Phil Thompson phil at riverbankcomputing.co.uk
Sat Jul 28 16:53:40 BST 2007

On Saturday 28 July 2007 4:36 pm, Giovanni Bajo wrote:
> 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

No I'm not. We are only discussing /Transfer/ because you originally said that 
not using sipTransferObj fixed the leak.

The leak that your test case demonstrated had nothing to do with /Transfer/ or 
sipTransferObj. If you still have a leak then I need another test case.

> 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".

Your stl.sip code seemed fine (apart from the two minor comments I made).


More information about the PyQt mailing list