Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 10th, 2005, 05:35 PM
ben.held@staarinc.com
Guest
 
Posts: n/a
Default Memory leak in PyImport_ReloadModule - URGENT

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!

  #2  
Old August 11th, 2005, 10:05 AM
Michael Hudson
Guest
 
Posts: n/a
Default Re: Memory leak in PyImport_ReloadModule - URGENT

ben.held@staarinc.com writes:
[color=blue]
> 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;[/color]

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).
[color=blue]
> Help![/color]

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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles