Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'd suggest to report this issue to https://github.com/sagemath/sage/issues

A surprising workaround for memory leak issues is using multiprocessing, which thanks to spawning processes can force memory release in a hard way. As a positive side effect, it can also give code a noticeable speed-up.

Here is a rewrite of your loops using multiprocessing:

import multiprocessing

def my_solve_mod(tu):
    t,u = tu
    return t, 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)

temp=[]
with multiprocessing.Pool() as pool:
    for t,lll in pool.imap( my_solve_mod, Tuples((0..p^r-1),2) ):
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

You may like to check documentation on multiprocessing for fine-tuning of this computation (e.g. assigning forming bigger chunks of data for parallel processing).

PS. On a side note, you don't need to form lists like [A..B] in your loops, using generators (A..B) instead is faster and memory-savvy.

I'd suggest to report this issue to https://github.com/sagemath/sage/issues

A surprising workaround for memory leak issues is using multiprocessing, which thanks to spawning processes can force memory release in a hard way. As a positive side effect, it can also give code a noticeable speed-up.

Here is a rewrite of your loops using multiprocessing:

import multiprocessing

def my_solve_mod(tu):
    t,u = tu
    return t, 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)

temp=[]
with multiprocessing.Pool() as pool:
    for t,lll in pool.imap( my_solve_mod, Tuples((0..p^r-1),2) ):
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

You may like to check documentation on multiprocessing for fine-tuning of this computation (e.g. assigning forming bigger chunks of data for parallel processing).

PS. On a side note, you don't need to form lists like [A..B] in your loops, using generators (A..B) instead is faster and memory-savvy.

I'd suggest to report this issue to https://github.com/sagemath/sage/issues

A surprising workaround for memory leak issues is using multiprocessing, which thanks to spawning processes can force memory release in a hard way. As a positive side effect, it can also give code a noticeable speed-up.

Here is a rewrite of your loops using multiprocessing:

import multiprocessing

def my_solve_mod(tu):
    t,u = tu
    return t, 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)

temp=[]
with multiprocessing.Pool() as pool:
    for t,lll in pool.imap( my_solve_mod, Tuples((0..p^r-1),2) ):
        LL=len(lll)
        temp.append(LL)
        print('LL ist gerade gleich: ')
        print(LL)
        print('t ist gerade gleich: ')
        print(t)
        #print("memory usage: " + str(get_memory_usage()))
        gc.collect()

You may like to check documentation on multiprocessing for fine-tuning of this computation (e.g. forming bigger chunks of data for parallel processing).

PS. On a side note, you don't need to form lists like [A..B] in your loops, using generators (A..B) instead is faster and memory-savvy.