Mailing List Archive

[ python-Bugs-1256669 ] Significant memory leak with PyImport_ReloadModule
Bugs item #1256669, was opened at 2005-08-11 08:49
Message generated for change (Comment added) made by collinwinter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1256669&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Ben Held (bheld)
Assigned to: Nobody/Anonymous (nobody)
Summary: Significant memory leak with PyImport_ReloadModule

Initial Comment:
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.


----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2005-09-14 13:53

Message:
Logged In: YES
user_id=1344176

I've been unable to verify this on Linux. I've tested python
versions 2.2.3, 2.3.5 and 2.4.1, all compiled with gcc 3.3.5
on Debian 3.1 under kernel 2.6.8. I used the sample program
provided by Ben, modified with an infinite loop over the
PyImport_ReloadModule/PyDECREF(pModule2) lines, sleeping for
1 second after every 25 iterations. I tested reloading the
modules distutils, os.path, distutils.command.sdist for 300+
iterations each under each python version. No memory leak
was observed.

----------------------------------------------------------------------

Comment By: Ben Held (bheld)
Date: 2005-08-16 09:56

Message:
Logged In: YES
user_id=1327580

Boundschecker shows the leak and I have verified this by
watching the process memory increase via the task manager.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-08-13 09:34

Message:
Logged In: YES
user_id=21627

How do you know there is a memory leak?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1256669&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[ python-Bugs-1256669 ] Significant memory leak with PyImport_ReloadModule [ In reply to ]
Bugs item #1256669, was opened at 2005-08-11 12:49
Message generated for change (Comment added) made by bheld
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1256669&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Ben Held (bheld)
Assigned to: Nobody/Anonymous (nobody)
Summary: Significant memory leak with PyImport_ReloadModule

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Ben Held (bheld)
Date: 2005-09-14 18:09

Message:
Logged In: YES
user_id=1327580

This behavior is evident with Python 2.3.5 built on Windows
with VC++ 6.0.

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2005-09-14 17:53

Message:
Logged In: YES
user_id=1344176

I've been unable to verify this on Linux. I've tested python
versions 2.2.3, 2.3.5 and 2.4.1, all compiled with gcc 3.3.5
on Debian 3.1 under kernel 2.6.8. I used the sample program
provided by Ben, modified with an infinite loop over the
PyImport_ReloadModule/PyDECREF(pModule2) lines, sleeping for
1 second after every 25 iterations. I tested reloading the
modules distutils, os.path, distutils.command.sdist for 300+
iterations each under each python version. No memory leak
was observed.

----------------------------------------------------------------------

Comment By: Ben Held (bheld)
Date: 2005-08-16 13:56

Message:
Logged In: YES
user_id=1327580

Boundschecker shows the leak and I have verified this by
watching the process memory increase via the task manager.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-08-13 13:34

Message:
Logged In: YES
user_id=21627

How do you know there is a memory leak?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1256669&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[ python-Bugs-1256669 ] Significant memory leak with PyImport_ReloadModule [ In reply to ]
Bugs item #1256669, was opened at 2005-08-11 05:49
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1256669&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Ben Held (bheld)
Assigned to: Nobody/Anonymous (nobody)
Summary: Significant memory leak with PyImport_ReloadModule

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-09-19 23:02

Message:
Logged In: YES
user_id=33168

I just tested with Python 2.4.2 on Linux with valgrind. It
doesn't report any leaks. So this could be specific to
Python 2.3.5, Windows, VC++ 6.0 or some other variation.

Can you provide more info? For example, what module are you
passing on the command line? Can you provide that code?
What objects specifically do you think are leaking? Where
were they allocated?

----------------------------------------------------------------------

Comment By: Ben Held (bheld)
Date: 2005-09-14 11:09

Message:
Logged In: YES
user_id=1327580

This behavior is evident with Python 2.3.5 built on Windows
with VC++ 6.0.

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2005-09-14 10:53

Message:
Logged In: YES
user_id=1344176

I've been unable to verify this on Linux. I've tested python
versions 2.2.3, 2.3.5 and 2.4.1, all compiled with gcc 3.3.5
on Debian 3.1 under kernel 2.6.8. I used the sample program
provided by Ben, modified with an infinite loop over the
PyImport_ReloadModule/PyDECREF(pModule2) lines, sleeping for
1 second after every 25 iterations. I tested reloading the
modules distutils, os.path, distutils.command.sdist for 300+
iterations each under each python version. No memory leak
was observed.

----------------------------------------------------------------------

Comment By: Ben Held (bheld)
Date: 2005-08-16 06:56

Message:
Logged In: YES
user_id=1327580

Boundschecker shows the leak and I have verified this by
watching the process memory increase via the task manager.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-08-13 06:34

Message:
Logged In: YES
user_id=21627

How do you know there is a memory leak?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1256669&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com