Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get rid of a memory-leak when solving euqations modulo an integer with sage

Hi,

I am running into a memory leak if I execute the following sage code. I tried to get rid of the problem by using the garbage collector, but - after some time - my computer crashes anyway. I'd be thankful for any help.

p=3
r=2
n=7

import gc
gc.enable()

R=Integers(p^r)
elts=list(R)
elts

StrTotal=''
for i in [1..n-1]:
    StrTotal=StrTotal+'a_'+str(i)+','

StrTotal=StrTotal+'a_'+str(n)
StrTotal=var(StrTotal)
m=matrix([[1,0],[0,1]])
for i in [1..n]:
    m=matrix([[eval('a_'+str(i)),-1],[1,0]])*m

m_new = m + matrix([[1,0],[0,1]])
m_new

temp=[]
for t in [0..p^r-1]:
    for u in [0..p^r-1]:
        lll=solve_mod([a_1==t, a_2==u, m_new[0][0]==0, m_new[0][1]==0, m_new[1][0]==0, m_new[1][1]==0],p^r)
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        lll=0
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

temp

TEMP=sum(temp)
TEMP

How to get rid of a memory-leak when solving euqations modulo an integer with sage

Hi,

I am running into a memory leak if I execute the following sage code. I tried to get rid of the problem by using the garbage collector, but - after some time - my computer crashes anyway. I'd be thankful for any help.

p=3
r=2
n=7

import gc
gc.enable()

R=Integers(p^r)
elts=list(R)
elts

StrTotal=''
for i in [1..n-1]:
    StrTotal=StrTotal+'a_'+str(i)+','

StrTotal=StrTotal+'a_'+str(n)
StrTotal=var(StrTotal)
m=matrix([[1,0],[0,1]])
for i in [1..n]:
    m=matrix([[eval('a_'+str(i)),-1],[1,0]])*m

m_new = m + matrix([[1,0],[0,1]])
m_new

temp=[]
for t in [0..p^r-1]:
    for u in [0..p^r-1]:
        lll=solve_mod([a_1==t, a_2==u, m_new[0][0]==0, m_new[0][1]==0, m_new[1][0]==0, m_new[1][1]==0],p^r)
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        lll=0
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

temp

TEMP=sum(temp)
TEMP

How to get rid of a memory-leak when solving euqations modulo an integer with sagesage?

Hi,

I am running into a memory leak memory-leak if I execute the following sage code. I tried to get rid of the problem by using the garbage collector, but - after some time - my computer crashes anyway. I'd be thankful for any help.

p=3
r=2
n=7

import gc
gc.enable()

R=Integers(p^r)
elts=list(R)
elts

StrTotal=''
for i in [1..n-1]:
    StrTotal=StrTotal+'a_'+str(i)+','

StrTotal=StrTotal+'a_'+str(n)
StrTotal=var(StrTotal)
m=matrix([[1,0],[0,1]])
for i in [1..n]:
    m=matrix([[eval('a_'+str(i)),-1],[1,0]])*m

m_new = m + matrix([[1,0],[0,1]])
m_new

temp=[]
for t in [0..p^r-1]:
    for u in [0..p^r-1]:
        lll=solve_mod([a_1==t, a_2==u, m_new[0][0]==0, m_new[0][1]==0, m_new[1][0]==0, m_new[1][1]==0],p^r)
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        lll=0
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

temp

TEMP=sum(temp)
TEMP
click to hide/show revision 4
None

How to get rid of a memory-leak when solving euqations modulo an integer with sage?

Hi,

I am running into a memory-leak if I execute the following sage code. I tried to get rid of the problem by using the garbage collector, but - after some time - my computer crashes anyway. I'd be thankful for any help.

p=3
r=2
n=7

import gc
gc.enable()

R=Integers(p^r)
elts=list(R)
elts

StrTotal=''
for i in [1..n-1]:
    StrTotal=StrTotal+'a_'+str(i)+','

StrTotal=StrTotal+'a_'+str(n)
StrTotal=var(StrTotal)
m=matrix([[1,0],[0,1]])
for i in [1..n]:
    m=matrix([[eval('a_'+str(i)),-1],[1,0]])*m

m_new = m + matrix([[1,0],[0,1]])
m_new

temp=[]
for t in [0..p^r-1]:
    for u in [0..p^r-1]:
        lll=solve_mod([a_1==t, a_2==u, m_new[0][0]==0, m_new[0][1]==0, m_new[1][0]==0, m_new[1][1]==0],p^r)
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        lll=0
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

temp

TEMP=sum(temp)
TEMP