[PyKDE] Memory leak with sip generated code
claus at slac.stanford.edu
Thu Nov 11 04:50:51 GMT 2004
In some sip-wrapped C++ code I wrote, I have a class CALcontributionIterator containing a virtual function:
virtual void log(unsigned tower, unsigned layer, CALlog log) = 0;
CALlog is a small class of 4 bytes that parses bit fields in its single unsigned data value. SIP allows this log method can be implemented in Python code.
The iterate() method in this class calls the virtual log() method as:
log(tower, layer, theLog);
The sip for this class is pretty bland:
unsigned iterate() /ReleaseGIL/;
virtual void log(unsigned /*tower*/, unsigned /*layer*/, CALlog /*log*/) = 0;
and for CALlog, as well:
CALlogEnd negative() const;
CALlogEnd positive() const;
Everything appears to work correctly other than that any Python usage of the CALlog object causes the program to leak memory. What is the proper way to transfer ownership of the stack allocated CALlog object instance in this situation?
I'm using SIP 4.1.1 on Windows XP.
More information about the PyQt