MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Huge memory leaks when importing two-dimensional array in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103451] Huge memory leaks when importing two-dimensional array in Mathematica
  • From: Alexey <lehin.p at gmail.com>
  • Date: Mon, 21 Sep 2009 19:29:09 -0400 (EDT)

Hello,
Consider the following (evaluated in Mathematica 7.01):

In[1]:= MemoryInUse[]
t = RandomReal[{-1, 1}, {1000000, 2}];
MemoryInUse[]
SetDirectory["C:/"]
t >> temp.dat
MemoryInUse[]
Quit[]
Out[1]= 10040344
Out[3]= 26058000
Out[4]= "C:\\"
Out[6]= 26065008

One may see that the matrix "t" takes less than 26Mb of memory. Now we
try
to import the file "temp.dat":

In[1]:= MemoryInUse[]
SetDirectory["C:/"]
t = << temp.dat;
MemoryInUse[]
Out[1]= 10039112
Out[2]= "C:\\"
Out[4]= 86058504

The same data takes more than 80Mb of memory! How this happens?

The same code in Mathematica 5.2 works as expected:

In[1]:=
MemoryInUse[]
t=RandomReal[{-1,1},{1000000,2}];
MemoryInUse[]
SetDirectory["C:/"]
t>>temp.dat
MemoryInUse[]
Pause[2]
Quit[]

Out[1]=
2128352

Out[3]=
2129928

Out[4]=
C:\

Out[6]=
2134576

In[1]:=
MemoryInUse[]
SetDirectory["C:/"]
t=<<temp.dat;
MemoryInUse[]

Out[1]=
2127256

Out[2]=
C:\

Out[4]=
2129344

This memory leak is critical for me because I can not import backwards
in
Mathematica 7 my file exported in this way from Mathematica 7. The
file size
is 512Mb and it may be imported in Mathematica 5.2 without
difficulties.

Any ideas?


  • Prev by Date: Piecewise Constant Interpolation
  • Next by Date: Re: Re: Capturing the output(s) from a Manipulate?
  • Previous by thread: Re: Piecewise Constant Interpolation
  • Next by thread: Re: Huge memory leaks when importing two-dimensional array in Mathematica