Opened 13 years ago

Closed 14 months ago

#183 closed bug (fixed)

memory leak when mapping ideals?

Reported by: Simon King Owned by: hannes
Priority: major Milestone: 3-1-1
Component: memory leak Version: 3-1-0
Keywords: map, ideal Cc:

Description

reported on Nov 6, 2009 by Simon King:

I observed the following:

ring r = 2, (x(1..100)),dp; ideal i; for (int n=100;n>=1;n--) { i[n]=x(n)2; } map m = r,i; ideal j = maxideal(3); j = j[1..500]; option(mem); ideal k; for (n=1;n<=1000;n++){k=m(j);print(memory(0));}

[1753k]1910152 2002280 [2756k]2094352 2186424 2278496 2370568 [1291k]1049192 1111080 1169024 1226912 1284800 1342688 1400576 1458464 [2294k]1516352 1574240 1632128 1690072 1747960 1805848 1863736 1921624 1979512 2037400 2095288 2153176 2211120 2269008 2326896 2384784 2442672 [3297k]2500560 2558448 2616336 2674224 2732112 2790056 2847944 2905832 ...

Why is the memory consumption constantly growing, although the memory allocation of the ideal k should be constant?

Actually it *is* constant if one does not map j, i.e., if one has { k=j; } or { kill k; ideal k=j; } in the loop.

Can other people verify it (I am using the Singular version that is shipped with Sage)?

Note that the memory consumption remains constant if I map polynomials rather than ideals:

ring r = 2, (x(1..100)),dp; ideal i; for (int n=100;n>=1;n--) { i[n]=x(n)2; } map m = r,i; ideal j = maxideal(3); j = j[1..500]; option(mem); poly p; int t; ideal k; for (n=1;n<=1000;n++){ for (t=1;t<=500;t++) { p=j[t]; k[t]=m(p); };

print(memory(0));} [1753k][489k]509816 509816 509816 509816 509816 509816 509816 509816 509816 509816 509816 ...

So, it seems to me that there is a memory leak that occurs if one maps ideals. Killing and reallocating ideals is fine, and mapping of polynomials is fine.

Best regards, Simon

Change History (6)

comment:1 Changed 13 years ago by hannes

current status: most, but not all memery leaks found and fixed

comment:2 Changed 13 years ago by seelisch

Component: dontKnowmemory leak

comment:3 Changed 9 years ago by kroeker@…

issue still holds in singular-spielwiese

comment:4 Changed 9 years ago by kroeker@…

Since some of our examples for resolutions of singularities are memory-intensive, it would be nice if someone could look at the memory leaks again.

Jakob

comment:5 Changed 9 years ago by kroeker@…

it seems that the occurrence of the memory leak is connected to the relations of monomial degrees in ideal J:

input:

  option(mem);
   ring r = 0, (x),dp;
  
   ideal i = 1;
   map m = r,i;  
   def n,k;

   ideal J = x^2, x^4; // ok
   for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^2, x^5; //  memleak?
   for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^20, x^40, x^80; // ok
   for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^21, x^42, x^84; // ok
   for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^20, x^40, x^ 81; // memleak?
   for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^19, x^40, x^ 80; //  memleak?
   for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^20, x^39, x^80; //  memleak?
   for ( n=1; n<=3 ; n++)   {      k=m(J);      print( memory(0) );    }

   J = x^21, x^26 ; //  memleak?
   for ( n=1; n<=3 ; n++)   {      k=m(J);      print( memory(0) );    }

   def h;
   for (h=5;h<=15;h++) // ok for h = 5 and h = 10?
   {
       print("h = "+string(h) + ":" );
       J = x^5, x^h ; //  memleak?
       for ( n=1; n<=5 ; n++)   {      k=m(J);      print( memory(0) );    }
       print("");
   }

output:

>   option(mem);
>    ring r = 0, (x),dp;
>   
.    ideal i = 1;
>    map m = r,i;  
>    def n,k;
> 
.    ideal J = x^2, x^4; // ok
>    for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }
139896
139896
139896
> 
.    J = x^2, x^5; //  memleak?
>    for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }
139944
139992
140040
> 
.    J = x^20, x^40, x^80; // ok
>    for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }
140120
140120
140120
> 
.    J = x^21, x^42, x^84; // ok
>    for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }
140120
140120
140120
> 
.    J = x^20, x^40, x^ 81; // memleak?
>    for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }
140168
140216
140264
> 
.    J = x^19, x^40, x^ 80; //  memleak?
>    for ( n=1; n<=3; n++)   {      k=m(J);      print( memory(0) );    }
140528
140792
141056
> 
.    J = x^20, x^39, x^80; //  memleak?
>    for ( n=1; n<=3 ; n++)   {      k=m(J);      print( memory(0) );    }
141344
141632
141920
> 
.    J = x^21, x^26 ; //  memleak?
>    for ( n=1; n<=3 ; n++)   {      k=m(J);      print( memory(0) );    }
141960
142080
142200
> 
.    def h;
>    for ( h=5; h<=15; h++) // ok for h = 5 and h = 10?
.    {
.        print("h = "+string(h) + ":" );
.        J = x^5, x^h ; //  memleak?
.        for ( n=1; n<=5 ; n++)   {      k=m(J);      print( memory(0) );    }
.        print("");
.    }
h = 5:
142592
142584
142584
142584
142584

h = 6:
142616
142632
142656
142680
142704

h = 7:
142784
142848
142920
142992
143064

h = 8:
143144
143208
143280
143352
143424

h = 9:
143480
143520
143568
143616
143664

h = 10:
143680
143664
143664
143664
143664

h = 11:
143728
143760
143808
143856
143904

h = 12:
144016
144096
144192
144288
144384

h = 13:
144496
144576
144672
144768
144864

h = 14:
144952
145008
145080
145152
145224

h = 15:
145264
145272
145296
145320
145344

any ideas what is going on?

comment:6 Changed 14 months ago by hannes

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.