This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author illume
Recipients
Date 2006-06-30.04:06:43
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=2042


Note, that this patch doesn't fix all memory leaks of this
type.  For example, this code below doesn't release all the
memory after it is run.  It starts at about 3MB, goes up to
about 56MB and then only drops to 50MB.

AFAIK restarting python processes is still needed to reduce
memory usage for certain types of processes.


<pre>

import random
import os

def fill(map):
    random.seed(0)
    for i in xrange(300000):
        k1 = (random.randrange(100),
              random.randrange(100),
              random.randrange(100))
        k2 = random.randrange(100)
        if k1 in map:
            d = map[k1]
        else:
            d = dict()
        d[k2] = d.get(k2, 0) + 1
        map[k1] = d

if __name__ == "__main__":
    os.system('ps v')
    d = dict()
    fill(d)
    print "-"* 50
    print "\n" * 3
    os.system('ps v')
    del d

    import gc
    gc.collect()

    print "-"* 50
    print "\n" * 3
    os.system('ps v')
</pre>
History
Date User Action Args
2007-08-23 15:41:52adminlinkissue1123430 messages
2007-08-23 15:41:52admincreate