"Help needed - I don't understand how Python manages memory"

Hank @ITGroup hank.infotec at gmail.com
Sun Apr 20 14:46:37 CEST 2008


Apology for the previous offensive title~~
:)
Thanks, Rintsch, Arnaud and Daniel, for replying so soon.

I redid the experiment. What following is the record -

``starting python``                        # == Windows Task Manager: 
Python.exe  *4,076 *K memory-usage ==
 >>> st1='abcdefg'*999999         # == 10,952 K ==
 >>> del st1                                 # == *4,104*K ==
 >>> st1='abcdefg'*999999         # == 10,952 K ==
 >>> del st1                                 # == 4,104 K ==

 >>> li = ['abcde']*999999          # == 8,024 K ==
 >>> del li                                    # == *4,108* K ==

 >>> from nltk import FreqDist         # == 17,596 ==
 >>> fd = FreqDist()                        # == 17,596 ==
 >>> for i in range(999999):fd.inc(i)  # == 53,412 ==
 >>> del fd                                       # == *28,780* ==
 >>> fd2 = FreqDist()                       # == 28,780 ==
 >>> for i in range(999999):fd2.inc(i)  # == 53,412 ==
 >>> del fd2        # == 28,780 K ==

 >>> def foo():
...         fd3 = FreqDist()
...         for i in range(999999):fd3.inc(i)

 >>>  foo()         # == *28,788* K ==

 >>> def bar():
...         fd4 = FreqDist()
...         for i in range(999999):fd4.inc(i)
...         del fd4
                         # == 28,788 K ==
 >>> bar()         # == 28,788 K ==


That is my question, after ``del``, sometimes the memory space returns 
back as nothing happened, sometimes not... ...
What exactly was happening???

Best regards to all PYTHON people ~~
!!! Python Team are great !!!




More information about the Python-list mailing list