Bug report: memory leak in python 1.5.2
Michael Hudson
mwh21 at cam.ac.uk
Wed May 26 04:39:44 EDT 1999
Moshe Zadka <moshez at math.huji.ac.il> writes:
> On Wed, 26 May 1999, Greg McFarlane wrote:
>
> > Environment: Solaris 2.5.1, gcc
> >
> > The following script chews up cycles (as expected) as well as memory
> > (megabytes every few seconds).
> >
> > Does anyone know why?
> >
> > ======================================================================
> > import os
> > while 1:
> > os.environ['FOO'] = 'BAR'
> > ======================================================================
>
> No, but just to keep you sane:
> Mine does exactly the same,
>
> Python:
> Python 1.5.2 (#1, May 23 1999, 07:05:44) [GCC 2.8.1] on sunos4
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>
> uname -a:
> SunOS sunset 4.1.4 9 sun4m
>
> (I'll check it later on my linux box)
Well poking around the source to posixmodule.c one finds this:
/* XXX This leaks memory -- not easy to fix :-( */
if ((new = malloc(strlen(s1) + strlen(s2) + 2)) == NULL)
return PyErr_NoMemory();
(void) sprintf(new, "%s=%s", s1, s2);
if (putenv(new)) {
posix_error();
return NULL;
}
so at least someone knows about the problem.
Yours,
Michael
More information about the Python-list
mailing list