[Date Index]
[Thread Index]
[Author Index]
Re: Memory Leaks In Matrix Summation
*To*: mathgroup at smc.vnet.net
*Subject*: [mg5830] Re: [mg5822] Memory Leaks In Matrix Summation
*From*: gdl at nih.gov (G. David Lange)
*Date*: Tue, 28 Jan 1997 03:42:54 -0500
*Sender*: owner-wri-mathgroup at wolfram.com
>In summing a matrix I write over previous values
>in a do loop. However, as the resulting sample
>shows, the memory continues to grow (as it is in a loop
>it should, of course, write over itself). Is this
>a bug, and if so is there some means of avoiding it?
>
>
>In[1]:=
>xx=Array[Random[]+I Random[],{41,206}];
>
>In[2]:=
>(* 206 x 206 Matrix of zeros *)
>res0=Table[0,{i,1,206},{j,1,206}];
>
>In[3]:=
>(* Generate Matrix 206 x 206 ten times & sum over loop *)
>Do[
>
>xxk=xx[[k]];
>Print["#: ",k];
>res=Re[Outer[Times,Conjugate[#],#]&[xxk]];
>res0=res0+res;
>Print["Mem: ",N[MaxMemoryUsed[]/10^6]],
>
>{k,1,10}]
>
>#: 1
>Mem: 10.9363
>#: 2
>Mem: 13.3135
>#: 3
>Mem: 14.332
>#: 4
>Mem: 15.5276
>#: 5
>Mem: 17.7384
>#: 6
>Mem: 19.9492
>#: 7
>Mem: 22.16
>#: 8
>Mem: 24.3708
>#: 9
>Mem: 26.5816
>#: 10
>Mem: 28.7924
>
Mathematica keeps an infinite memory of all "In" and "Out" regardless of the way you program your loops. To defeat this use a command like
$HistoryLength=1.
The only penalty for this is that you cannot use % to refer to "Out"s farther back than your HistoryLength.
G. David Lange
Physiologist
Instrumentation and Computers Section of NINDS
Building 36 Rm 2A03
NIH
Bethesda, MD
20892
tel:(301)435-4537
FAX:(301)480-2492
e-mail:gdl at nih.gov
Prev by Date:
**Spectrogram**
Next by Date:
**statistics**
Previous by thread:
**Memory Leaks In Matrix Summation**
Next by thread:
**extracting elements from a list of lists**
| |