tahoe-lafs / zfec

zfec -- an efficient, portable erasure coding tool
Other
373 stars 44 forks source link

zfec.Encoder and zfec.Decoder leak memory on re-initialization #105

Open exarkun opened 8 months ago

exarkun commented 8 months ago

Each call to __init__ allocates memory for the fec matrix. When the object is collected, only the most recently allocated matrix is freed.

Observable with this program:

import zfec

e = zfec.Encoder(255, 256)
for i in range(100000):
    e.__init__(255, 256)

memory usage will grow as the program runs.

Encoder and Decoder should probably refuse multiple __init__ calls.

itamarst commented 8 months ago

... why would anyone call __init__ multiple times?

exarkun commented 8 months ago

... why would anyone call __init__ multiple times?

Other than to cause memory to leak? I can't think of a good reason.