Major memory leak during embedding Python in C++

B

Ben Held

Having recently upgraded to Python 2.4, I am having a large memory
leak with the following code built with VC++ 6.0:

PyObject *pName, *pModule;

Py_Initialize();
pName = PyString_FromString(argv[1]);

pModule = PyImport_Import(pName);
Py_DECREF(pName);

PyObject* pModule2 = PyImport_ReloadModule(pModule);
Py_DECREF(pModule2);
Py_DECREF(pModule);
Py_Finalize();
return 0;

I get leaks of over 500 kb. I have another program which is much more
complex, in which every call to PyImport_ReloadModule is leaking 200+
kb, even though I am calling Py_DECREF correctly.

Help!
 
J

Jon-Pierre Gentil

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ben said:
Having recently upgraded to Python 2.4, I am having a large memory
leak with the following code built with VC++ 6.0:

Your first mistake is that Python 2.3.3 is the latest version.
Wherever you got Python 2.4, I'd be scared.


- --
:: Jon-Pierre Gentil
:: PGP Key ID 0xA21BC30E
:: Jabber: (e-mail address removed)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkBuGB8ACgkQOrVFmaIbww7pBgCeNSQFcfLnAHVzEzXyxOZqZJfV
6D0Aniso/bD/iGxMtyqRhpF/QUoWTsu7
=JNV2
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top