You can fill your memory with something simpler
sage: l = range(10**9)
As far as I can see it has nothing to do with Sage or loops. In Python2
the range functions constructs a list. And in the above example, the
list is huge.
Vincent
On 15/12/2017 12:06, Marco Caselli wrote:
Hello there,
I am currently having trouble in memory management, I wrote a code that was
not supposed to store anything but actually it was using a massive amount
of memory. At a first glance, I thought it was related to some function in
my code, such as factor() for polynomials in a multivariate ring over a
finite field. I dug a bit deeper and the problem seems even at a lower
level:
def check_memory(k):
a=get_memory_usage()
silly_function(k)
return get_memory_usage()-a
def silly_function(k):
for i in range(10^k):
2+2
Notice that silly_function does not store neither return anything, so the
memory usage should be zero.
check_memory(9) returned 23446.37109375, this amount is in MB, so those are
23GB. This information is consistent with the data from top. At a second
run it returned just 972.62109375, which is still a lot.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.