Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Bug Report: 4th argument in function Partition' topicStudent Support Forum > General > "Bug Report: 4th argument in function Partition"

Help | Reply To Topic
Author Comment/Response
Luís d'Aguiar Brandão
12/22/04 1:23pm

Hello!

I think i've found a bug in mathematica, related to a very simple memory issue.

It took me a while, but I think I've narrowed it down to the essential point. When making use of the 4th argument (overhang option as described in the help section) of function partition, applied to a matrix bigger than a given dimension, it seems that memory is not conveniently desallocated. In the following I present an example:

(**********************************************)

In[1]:=
(* In this case (with n=249) memory is conveniently managed *)
n=249;
m1=MemoryInUse[];
Do[
t1=Table[Random[Integer],{n},{n}];
t2=Partition[t1,{n,n},{n,n},{1,1}];
,{i,500}]
m2=MemoryInUse[];
m2-m1

Out[5]=
509760

In[6]:=
(* In this case (with n=250) memory is not desallocated *)
n=250;
m1=MemoryInUse[];
Do[
t1=Table[Random[Integer],{n},{n}];
t2=Partition[t1,{n,n},{n,n},{1,1}];
,{i,500}]
m2=MemoryInUse[];
m2-m1

Out[10]=
249760344

In[11]:=
Quit[];

(**********************************************)

As you may note, the simple modification of n=249 to n=250 produces an exagerated 'memory in use' increment.

(**********************************************)


In[1]:=
(* Another example - this will take more resources (time and memory) to evaluate, but it will show how this bug is serious enough to make mathkernel quit *)
s=3;n=2^10;i=0;
While[True,
t1=Table[Random[Integer],{s*n},{s*n}];
t2=Partition[t1,{n,n},{n,n},{1,1}];
m1=MemoryInUse[];
Print["i=",++i,", Memory in use: ",m1];
]
i= 1 , Memory in use: 128278352
i= 2 , Memory in use: 178597680
i= 3 , Memory in use: 228917048
i= 4 , Memory in use: 279236416
i= 5 , Memory in use: 329555784
i= 6 , Memory in use: 379875152
i= 7 , Memory in use: 430194520
i= 8 , Memory in use: 480513888
i= 9 , Memory in use: 530833256
i= 10 , Memory in use: 581152624
i= 11 , Memory in use: 631471992
i= 12 , Memory in use: 681791360
i= 13 , Memory in use: 732110728
i= 14 , Memory in use: 782430096
i= 15 , Memory in use: 832749464
i= 16 , Memory in use: 883068832
i= 17 , Memory in use: 933388152
i= 18 , Memory in use: 983707472
i= 19 , Memory in use: 1034026792
i= 20 , Memory in use: 1084346112
i= 21 , Memory in use: 1134665432
i= 22 , Memory in use: 1184984752
i= 23 , Memory in use: 1235304072
i= 24 , Memory in use: 1285623416
i= 25 , Memory in use: 1335942784

No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.

(**********************************************)

In[1]:=
(* When not making use of the 4th argument (overhang option), memory is conserved as it should *)
s=3;n=2^10;i=0;
While[i<50,
t1=Table[Random[Integer],{s*n},{s*n}];
t2=Partition[t1,{n,n},{n,n}];
m1=MemoryInUse[];
Print["i=",++i,", Memory in use: ",m1];
]
i= 1 , Memory in use: 77626712
i= 2 , Memory in use: 77626672
i= 3 , Memory in use: 77626672
i= 4 , Memory in use: 77626672
i= 5 , Memory in use: 77626672
i= 6 , Memory in use: 77626672
i= 7 , Memory in use: 77626672
i= 8 , Memory in use: 77626672
i= 9 , Memory in use: 77626672
i= 10 , Memory in use: 77626672
i= 11 , Memory in use: 77626672
i= 12 , Memory in use: 77626672
i= 13 , Memory in use: 77626672
i= 14 , Memory in use: 77626672
i= 15 , Memory in use: 77626672
i= 16 , Memory in use: 77626648
i= 17 , Memory in use: 77626600
i= 18 , Memory in use: 77626552
i= 19 , Memory in use: 77626504
i= 20 , Memory in use: 77626456
i= 21 , Memory in use: 77626408
i= 22 , Memory in use: 77626360
i= 23 , Memory in use: 77626312
i= 24 , Memory in use: 77626288
i= 25 , Memory in use: 77626288

(**********************************************)

Note: My problem is not on the ability to produce the same result by other means, but on the ability to evaluate function partition without problems on memory management.

Best regards,
Luís d'Aguiar Brandão
2004/12/22

URL: ,
Help | Reply To Topic