I was asked to make a code that iterates over all matrices of given type
and size. And once again I see a memory leak. Here's an example code
n = 7
m = Integer(n*(n-1)/2)
for i in IntegerRange(2^m):
d = i.digits(base=2, padto=m)
l = [[1]+[0]*(n-1)]
for j in range(n-1):
l.append( d[(j+1)*j/2:(j+1)*(j+2)/2]+ [1] + [0]*(n-j-2) )
M = Matrix(l)
eig = sorted((M*M.transpose()).eigenvalues())[0]
if eig <= 0:
print "Foobar"
These kind of codes, where I make millions of small objects, compute
something and discard the object, seems to eat memory. Not much, but so
much that otherwise reasonable computable thing - say, something to run
for two days - will be impossible to do directly.
Is there anything I can do for these? (Other than running the code
part-by-part.)
This was ran on newest beta version.
--
Jori Mäntysalo