[Mojonation-devel] Re: memory leak with dynamically defined functions?

David Bolen db3l at fitlinxx.com
Tue Jul 17 02:31:39 CEST 2001

"Gregory P . Smith" <greg at mad-scientist.com> writes:

> It doesn't appear to leak memory for me either.  The difference as
> zooko noticed does show up though:
> His first example that didn't use a function holding a reference via
> default parameters -immediately- released the consumed memory when the
> reference to blarg was deleted.
> The version above that uses the function reference doesn't seem to
> ever release that memory even when the reference to blarg has been
> deleted.  (yet it doesn't go above 34M when I put it in a while 1 loop
> as you have)

That could just be a behavior of the underlying memory allocation from
the OS.  Depending on OS (and if variable, allocation implementation),
an application might not actually yield its working set memory back to
the system, but just reuse it within its own memory space as necessary.

>From the behavior described, I'd guess that the allocation system in
use on the test system was willing to give back memory if it was
possible to do so contiguously at the top of the currently allocated
space for the application in simple cases, but not in other cases
(where the space becomes more fragmented).

This isn't really a Python issue (I expect Python has properly freed
all relevant memory), but more a platform memory allocation issue.

-- David
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list