[pypy-issue] [issue1769] Memory leak

bug tracker at bugs.pypy.org
Wed May 14 18:13:14 CEST 2014


bug <ddvmssr+2pxkfw at sharklasers.com> added the comment:

class Trie:
    def __init__(ss):
        ss.prefixes = [False]*100
   
    def add(ss, i, depth):
        prefixes = ss.prefixes[:]
        if depth:
            t = ss.prefixes[i%100]
            if not t:
                t = Trie()
            prefixes[i%100] = t.add(i//100, depth-1)
        else:
            prefixes[i%100] = True
       
        n = Trie()
        n.prefixes = prefixes
        return n
 
 
#higher j uses more memory even after print('done')
#the old memory should be freed at t = Trie()
for j in range(10):
    t = Trie()
    for i in range(10**5):
        t = t.add(i, 3)
 
print('done')
while t:
    continue

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1769>
________________________________________


More information about the pypy-issue mailing list