Memory increasing when using constant pi

asked 2019-11-15 11:55:10 -0600

fabio_fc gravatar image

Hello everybody,

I have some memory problems when executing the following for cycle in SageMath (version 8.9 on Linux Mint 19.2):

sage: precision = 165
sage: FFF = RealField(prec = precision)
sage: MAX = 32
sage: gpi = FFF.pi()
sage: trange = [2..555]
....: for t in trange:
....:     d = t*[exp (2*gpi*I*i/MAX) for i in range(MAX)]
....:     print "memory usage: " + str(get_memory_usage())

which outputs

memory usage: 2283.20703125 
memory usage: 2283.20703125 
memory usage: 2283.20703125
...
memory usage: 2292.2421875
memory usage: 2292.4921875
memory usage: 2292.4921875
memory usage: 2292.4921875

I found that the situation improves if I remove the gpi variable from the for cycle, obtaining

memory usage: 2274.86328125
memory usage: 2274.86328125
memory usage: 2274.86328125
...
memory usage: 2275.12109375
memory usage: 2275.12109375

Is there some way to avoid this increment in memory?

Thank you in advance

edit retag flag offensive close merge delete