[New-bugs-announce] [issue3063] memory leak in random number generation

Grant Tang report at bugs.python.org
Sun Jun 8 17:46:09 CEST 2008

New submission from Grant Tang <grant.tang at gmail.com>:

#the following code consume about 800M memory, which is normal
n = 100000000
data = [0.0 for i in xrange(n)]

#however, if I assign random number to data list, it will consume extra 
2.5G memory.
from random import random
for s in xrange(n):
    data[i] = random()

#even if I delete data, only 800M memory released
del data

#call gc.collect() does not help, the extra 2.5G memory not released
import gc

only when I quit Python, the memory is released. Same effect if I use 
random number generator from numpy. 
Same effect even if I just say data[i] = atpof("1.26")
I tried it in both Python 2.4 and 2.5 on linux 64bit and 32bit.

components: None
messages: 67833
nosy: gtang
severity: normal
status: open
title: memory leak in random number generation
type: resource usage
versions: Python 2.4, Python 2.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list