Memory leak when embedding Python 2.2?

Jens Scheidtmann scheidtm at mx.uni-saarland.de
Wed Jan 16 12:20:13 EST 2002


Dear Readers,

I am trying to embed Python 2.2 in my MS Visual C++ project.
The debug facilities of VC++ detect memory leaks with Python, but not
without Python. 

I have an CPhyton object only with constructor and destructor. 
 
-------
CPython::CPython()
{
  Py_Initialize();
}

CPython::~CPython()
{
  Py_Finalize();
}
--------
The object is created on start of my application and deleted immediately
afterwards in the CXYZApp class generated by the application wizard. 

-----
m_pPython = new CPython;
if (m_pPython == NULL) {
  exit(1);
}
else { 
  delete m_pPython;
  m_pPython = NULL;
}
-----

On exit of the application the debugging facilities of VC++ report lots
of 
memory leaks, which are gone, if I comment out the Py_Initialize and
Py_Finalize in the Python-object. 

Have you got similar problems using 2.2?
Or does embedding 2.2 in your project work like a charm?

I am using Microsoft Visual C++ 6.0 Enterprise Edition.
I have downloaded Python 2.2 from python.org and compiled it using the
provided VC++ workspace (Using Win32 Debug settings and python, pythonw
projects).
I copied python22_d.dll into WINNT/system32 on my W2000pro system.
I have added python-2.2\pcbuild to 
"Tools/Options.../Directories/Library Files" and python-2.2\pc and
python-2.2\include to "Tools/Options.../Directories/Include Files".
In addition I have installed Python 2.2 using the supplied installer
from python.org (in a different directory).
 
Thanks in advance,

Jens Scheidtmann
--
Universität des Saarlandes
Technische Chemie
Jens Scheidtmann
Am Markt Zeile 3
66125 Saarbrücken-Dudweiler
Tel.: + 49 681 302 64139
Fax.: + 49 681 302 2343



More information about the Python-list mailing list