Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Memory increasing when using constant pi

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