MathGroup Archive 1999

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

Search the Archive

Re: Re: Freeing memory in Mathematica

  • To: mathgroup at
  • Subject: [mg19558] Re: [mg19546] Re: Freeing memory in Mathematica
  • From: David Withoff <withoff at>
  • Date: Wed, 1 Sep 1999 23:06:58 -0400
  • Sender: owner-wri-mathgroup at

> bettina_hansen at wrote in message <7q9g8i$o43 at>...
> >Hallo everyone.
> >
> >I was trying to make a Mathematica program which make some calculations
> >on several long (and very large) lists. However, after the calculation
> >of each list, the list is no longer needed. So I tried to delete it
> >using listname=. However it seems that this is not working in the sense
> >that it is still present in memory.

The lists are saved in values for Out.

> >Finally I found out how to free the
> >memory, see the following. Can anyone tell me how to do this more
> >'nice'? (i.e. without the use of the NoUse variable?)
> >
> >  Print[MemoryInUse[]]
> >  list=Table[Sqrt[i],{i,1,20000}]; NoUse=1;
> >  Print[MemoryInUse[]]
> >  list=.
> >  Print[MemoryInUse[]]
> >
> >Gives:
> >  836032
> >  1906744
> >  836352

You can set $HistoryLength to zero if you do not want results saved
in values for Out, or you could put any small, non-Null expression
in place of "NoUse=1".

> It turns
> out that you can replace the assignment of NoUse by anything with a non-null
> value - e.g. the number 42. It also seems that even when the memory in use
> does not go down, if you test it afterwards it HAS gone back down - so my
> guess is that Mathematica is holding on to the value as a possible return
> value from the compound expression
> David Bailey
> Salford Software
> db at

Yes, the value of Out records the last non-Null result if the input
was a compound expression.

Dave Withoff
Wolfram Research

  • Prev by Date: RE: Automatic Display in MatrixForm
  • Next by Date: LaTeX Output
  • Previous by thread: RE: Automatic Display in MatrixForm
  • Next by thread: Re: Freeing memory in Mathematica