By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

Major memory leak during embedding Python in C++

P: n/a
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!
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ben Held wrote:
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: jg*****@jabber.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkBuGB8ACgkQOrVFmaIbww7pBgCeNSQFcfLnAH VzEzXyxOZqZJfV
6D0Aniso/bD/iGxMtyqRhpF/QUoWTsu7
=JNV2
-----END PGP SIGNATURE-----
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.