[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] Memory leak with sip generated code
From:       "Claus, Richard" <claus () slac ! stanford ! edu>
Date:       2004-11-11 4:50:51
Message-ID: 35C208A168A04B4EB99D1E13F2A4DB015E5B35 () exch-mail1 ! win ! slac ! stanford ! edu
[Download RAW message or body]

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:

      ...
      {
        CALlog theLog(datum);
        log(tower, layer, theLog);
      }
      ...

The sip for this class is pretty bland:

class CALcontributionIterator
{
%TypeHeaderCode
#include "CALcontributionIterator.h"
%End

public:
  CALcontributionIterator();
  ~CALcontributionIterator();

  unsigned iterate()  /ReleaseGIL/;

  virtual void log(unsigned /*tower*/, unsigned /*layer*/, CALlog /*log*/) = 0;
};

and for CALlog, as well:

class CALlog
{
%TypeHeaderCode
#include "CALlog.h"
%End

public:
  CALlog();
  ~CALlog();

  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.

	Thanks,
		Ric

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic