Sage 8.1 eats memory until system freeze
Hi, I have a quite long code (which uses arbitrary precision real numbers) which runs perfectly on Sage 7.5.1 (ppa for Mint 17.3 - Ubuntu 14.04). On Sage 8.1 (sage-8.1-Ubuntu_14.04-x86_64.tar.bz2) it starts to eat the memory until it freezes the system. I would like to help in debugging. Is there something that I can try/run/test? I can also upload the code, if necessary.
Finally, I have a minimal working code
def test(m,c,precision):
M = 3*m
RRR = RealField(prec = precision)
coef02 = [RRR(1/i) for i in [1..M+1]]
g = coef02[M]
for i in [M-1..2,step=-1]: # Horner
g = x*g+coef02[i]
ME = 32
disk = [exp (2*pi.n(precision)*I*i/ME) for i in range(ME)]
gamma = abs(c)/2
ellipse = [(gamma*(w+c^2/(4*gamma^2)/w)) for w in disk]
epsilon1 = max([abs(g(x=z)) for z in ellipse])
return
m = 40
for c in [1/2..10,step=1/2]:
for ell in [1..10]:
test(m,c,165)
If I run this in 7.5.1, I see (in top) the memory percentage stable around 2.5. If I run in 8.1, it grows up to 7.3 before code termination. If I increase the length of the loops, memory usage continues to grow.
Use a profiler, e.g.
https://docs.python.org/2/library/profile.html
to see where the code spends the most time. (Implement somehow hard breaks to make it finish.) Then look exactly at the corresponding points. It is hard to do this without the code.
Some IDEs may have a profiler functionality, e.g.
https://www.jetbrains.com/help/pycharm/optimizing-your-code-using-profilers.html
(Never tried it with sage.)
It is also a good idea to run the code in the debugger and follow the jumps a while till the run freezes...
Note: We only know that approximate values are used. Make sure, that all sage algorithms used do not require exact algebra to terminate.