python has memory leak?

Jean-Paul Calderone exarkun at divmod.com
Tue Apr 22 21:58:39 EDT 2008


On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan at gmail.com wrote:
>Hi all,
>
>I feel that my python script is leaking memory. And this is a test I
>have:
>
> [snip]
>

The test doesn't demonstrate any leaks.  It does demonstrate that memory
usage can remain at or near peak memory usage even after the objects for
which that memory was allocated are no longer live in the process.  This
is only a leak if peak memory goes up again each time you create any new
objects.  Try repeated allocations of a large dictionary and observe how
memory usage rises and falls.

Python 2.5 does a somewhat better job of releasing memory when actual use
falls below peak, but this is a difficult thing to do perfectly.

Jean-Paul



More information about the Python-list mailing list