Embedding Python in an MFC application

Darin Willits darin at REMOVEblueyonder.co.uk
Tue Apr 22 14:47:34 EDT 2003


Hi,

I know that the first response to this will be "Why are you embedding
when you could just extend?" but please believe that I have my reasons
and for now this is what I have to do.  However I am something of a
newbie with this stuff so bear with me.

Now for the question:  I have created a simple MFC application (with
AppWizzard) which mearly calls Py_Initialize() and Py_Finalize() in the
OnInit function.  When I build and run this app it starts the python
interpreter fine, and shuts it down without a noticable problem. 
However when I close the application I get a huge memory leak.  Now for
the wieird part.  If I switch the above application from linking to MFC
as a shared dll, to statically linking to MFC the memory dump is gone. 
Why is this?  This is driving me nuts as I really need to use the MFC
as a shared dll.

Please tell me I am missing something simple.  I am learning this stuff
as I go and this one has me stumped.

Thanks,

Darin




More information about the Python-list mailing list