Memory leak in PyImport_ReloadModule - URGENT

Michael Hudson mwh at python.net
Thu Aug 11 05:00:35 EDT 2005


ben.held at staarinc.com writes:

> 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;

Given that the builtin function reload() does more or less the same
thing, it seems likely that there's something odd about your embedding
that is making the difference.

Does it make a difference which module you reload?

I notice that you're using VC++ 6.0.  Is your Python built with VC6
too?  (The python.org distribution is built with 7 -- or 7.1, I forget
which).

> Help!

You might want to file a bug report.

Cheers,
mwh

-- 
  Like most people, I don't always agree with the BDFL (especially
  when he wants to change things I've just written about in very
  large books), ...
         -- Mark Lutz, http://python.oreilly.com/news/python_0501.html



More information about the Python-list mailing list