Opened 5 years ago

Last modified 5 years ago

#17494 new defect

Memory leak for letterplace implementation of free algebras

Reported by: SimonKing Owned by:
Priority: major Milestone: sage-6.5
Component: memleak Keywords:
Cc: malb Merged in:
Authors: Reviewers:
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

At #17435, I noticed the following:

sage: L.<x,y,z> = FreeAlgebra(GF(25,'t'), implementation='letterplace')
sage: p = x^4+x*y*x*z+2*z^2*x*y
sage: for i in range(20):
....:     m = get_memory_usage()
....:     for j in range(300):
....:         z = p^7
....:     print get_memory_usage()-m
....: 
2.0
2.0
2.0
2.0
0.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
0.0
2.0
2.0

This leak even pertains when #16958 is applied.

Change History (4)

comment:1 Changed 5 years ago by SimonKing

  • Report Upstream changed from Not yet reported upstream; Will do shortly. to Reported upstream. Developers acknowledge bug.

Here is the corresponding computation in Singular (as shipped with Sage):

./sage -singular
                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-7
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Aug 2013
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "freegb.lib";
// ...
> ring r = 0,(x,y,z),dp;
> def R = makeLetterplaceRing(30);
> setring R;
> poly p = x(1)*x(2)*x(3)*x(4) + x(1)*y(2)*x(3)*z(4) + 2*z(1)*z(2)*x(3)*y(4);
> poly q = lpPower(p,7);
> memory(0); memory(1);  memory(2);
3494312
8634368
8667136
> q = lpPower(p,7);
> memory(0); memory(1);  memory(2);
5393504
10731520
10764288
> q = lpPower(p,7);
> memory(0); memory(1);  memory(2);
7292696
12828672
12861440
> q = lpPower(p,7);
> memory(0); memory(1);  memory(2);
9191888
14925824
14958592
> Auf Wiedersehen.

So, the leak is in Singular, not in the wrapper.

comment:2 Changed 5 years ago by SimonKing

  • Report Upstream changed from Reported upstream. Developers acknowledge bug. to Fixed upstream, in a later stable release.

If I understand correctly, the leak is fixed in a later version of singular. Hope it will be in Sage soon...

comment:4 in reply to: ↑ 3 Changed 5 years ago by nbruin

Replying to rws:

Maybe related: http://ask.sagemath.org/question/29444/high-memory-usage-when-substituting-variables/

I think that points to a more basic and hence more severe memory leak.

import gc, collections
gc.collect()
old=set( id(a) for a in gc.get_objects())
R.<x,y,z>=ZZ[]
f=12^2*(x^4+y^4)-15^2*(x^2+y^2)*z^2+350*x^2*y^2+9^2*z^4
pt=[1,2,3]
m=get_memory_usage()
for i in xrange(10^5):
    temp=f(x=x+pt[0]*z,y=y+pt[1]*z,z=pt[2]*z) #This also uses a lot of memory.
    if (i% 100) == 0:
        print get_memory_usage()-m
            
gc.collect()
new=collections.Counter( str(type(a)) for a in gc.get_objects() if id(a) not in old)
new

This code clearly shows leaking and it shows the leak is not in python reference counted objects. I would find it hard to believe that such a basic leak in normal polynomial arithmetic would go unnoticed in Singular, so I would expect the error is somewhere in the sage/singular interface.

Note: See TracTickets for help on using tickets.