[Tutor] memory management

Christian Tismer tismer@appliedbiometrics.com
Sun, 18 Apr 1999 17:01:52 +0200


David Ascher wrote:
> 
> On Sat, 17 Apr 1999, Christian Tismer wrote:
> >
> > No, AFAIK Python does never free memory which it had
> > acquired before, but it will reuse it.
> 
> Uh?  Sorry, Christian, that's false.  Python frees the memory just fine
> when no references are held (for those who care, The *operating system*
> may not show it as freed -- that's what Linux does, for example.  Windows
> NT, on the other hand, shows the memory as freed.

(ick!) Is this really so? I thought I'd read this some time ago
and never investigated further, since I had the experience
that my WIndoze swapfile never shrunk after PythonWin had used
and freed a large chunk of memory. When I shut down my session
and wait a couple of seconds, I can see my swapfile shrunk again.
Maybe this mislead me to make wrong assumptions.

Hmm. You are absolutely sure?
Can it be an effect of memory fragmentation that it doesn't
get released under circumstances?
I just did (using PythonWin)

>>> big = range(10000000)
>>> 

and watched my swapfile frow from small to 233 MB.
Then I did a del on big. This took even more time than
creating it, btw. Touching all the refcounts again seems
to be quite a challenge for my harddisk. I have the strong
impression that releasing objects should try to do this in
reverse order. Without explicit measure, my guess is it takes
5 times as long to release this chunk.

After a couple of seconds, my swapfile melted down to 192 MB.
You are right. Some memory is freed. I'm just wondering about 
the rest? After closing my PyWin session, the swap file quickly
became as small as before. Can it be that I'm about to
find a memory leak?

cheers - chris

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home