ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 26 Sep 2018 04:18:13 -0500Memory leaks with matrix multiplication over GF(2)http://ask.sagemath.org/question/43769/memory-leaks-with-matrix-multiplication-over-gf2/Hello everyone,
I have memory leaks when I run this program:
#### Memory leaks with sage 8.3 and sage 8.1 !!!
n = 8
X = zero_vector(GF(2), n)
M = zero_matrix(GF(2), n, n)
for _ in range(10000000):
Y = M * X
I use debian buster and sage-8.3-Debian_GNU_Linux_9-x86_64.
Is there something I'm doing wrong?
Thanks !agrospelWed, 26 Sep 2018 04:18:13 -0500http://ask.sagemath.org/question/43769/Memory leak somewhere?http://ask.sagemath.org/question/34364/memory-leak-somewhere/My code is using massive amounts of memory (eventually), which I don't think should be the case. The memory use slowly increases until my computer runs out of memory. I tried enabling garbage collection, but that didn't help (or didn't help enough). I don't see any reason why this should use more and more memory. It takes somewhere between 5 and 10 hours for this program to use up my 16 GB of memory, but that memory user is increasing is clear quickly.
import numpy
trials = 5800
length = 5000
mean = 0
results = [0]*trials
data = [0]*length
for i in range(trials):
data[0] = numpy.random.normal(0,1)
for j in range(1, length):
data[j] = data[j-1] + numpy.random.normal(0,1)
for k in range(2, length):
if data[k] > 2*sqrt(k*log(log(k+1))):
results[i] += 1
mean += results[i]vukovSun, 07 Aug 2016 13:04:22 -0500http://ask.sagemath.org/question/34364/High memory usage when substituting variableshttp://ask.sagemath.org/question/29444/high-memory-usage-when-substituting-variables/I need to make a lot of variable substitutions in multivariate polynomials. However, I only need to store one polynomial at a time and I only need to make one substitution at a time. Nonetheless sage uses a lot of memory. This memory is not freed until sage is killed.
Here is a small example:
var("x y z")
# A polynomial in three variables (The Trott quartic):
poly=12^2*(x^4+y^4)-15^2*(x^2+y^2)*z^2+350*x^2*y^2+9^2*z^4
poly=poly.polynomial(ZZ)
pnt=[1,2,3]
# Makes a certain variable subsitution, defined by pt, n times.
def test_subs(f,pt,n):
for i in xrange(n):
temp=f.substitute(x=x+pt[0]*z,y=y+pt[1]*z,z=pt[2]*z)
#temp=f(x=x+pt[0]*z,y=y+pt[1]*z,z=pt[2]*z) #This also uses a lot of memory.
When i run `test_subs(poly,pnt,100000)` I can see the memory usage ticking up from around 1% up to nearly 2%. if I then run the function again the ticking starts at 2%, and so on. In the real problem I have my program eventually fills up all memory and then crashes.
Can you see why this is happening and do you know how to prevent it from happening?Olof BergvallTue, 15 Sep 2015 04:09:49 -0500http://ask.sagemath.org/question/29444/