[Python.NET] Memory Leak in MFC/C++ based Python Extended/Embedded code.

Brian Lloyd brian.lloyd at revolutionhealth.com
Tue Jan 8 15:19:47 CET 2008


Hi Dan - for regular Python embedding questions you'd be better off asking
on the standard Python list (this list is for an integration of Python with
.NET).

-Brian


On 1/7/08 9:10 PM, "Dan Trowbridge" <dan at thetrowbridgefamily.com> wrote:

> Hi all,
> 
> I have a MS Windows/MFC based C++ code that I have implemented Python
> embedding/extending in.  (I am using Visual Studio 2003.)  The code seems to
> do what I have intended except it always reports a memory leak when it
> exits.  I tried all kinds of things but there did not seem to be anything I
> could do to get rid of it.
> 
> So...
> 
> I built a new MFC project and the only things I added was...
> 
> #include <Python.h>
> 
> at the top of the application class .cpp file and the following two lines
> 
> Py_Initialize();
> Py_Finalize();
> 
> in the application class constructor.
> 
> The minimal code STILL reports a memory error.  It looks like the memory
> leak had nothing to do with my code.
> 
> Anybody have any ideas how to fix this?
> 
> Background: I am using Python 2.5.1.  I am not using BOOST::PYTHON (I am
> using BOOST::NUMERIC and BOOST::SHARED_PTR for other things in the code -
> maybe I should use BOOST::PYTHON - maybe their shared_ptr's would take care
> of this for me? ).  I also am not using SWIG or any other "helpers".
> 
> Any help would be greatly appreciated.  If this is not the right forum
> please advise where to post this.
> 
> It got to figure that someone has seen this before - considering as long as
> Python has been around and as big as the developer community is.
> 
> Thanks in advance for your collective help.
> 
> Dannyt
> 
> 
> 
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet

--------------------------
Brian Lloyd

brian.lloyd at revolutionhealth.com



More information about the PythonDotNet mailing list