469,353 Members | 2,093 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

Major memory leak during embedding Python in C++

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
1 1991
-----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.

Similar topics

10 posts views Thread by Debian User | last post: by
3 posts views Thread by Guy | last post: by
2 posts views Thread by Elbert Lev | last post: by
1 post views Thread by ben.held | last post: by
10 posts views Thread by Andrew Trevorrow | last post: by
18 posts views Thread by diffuser78 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.