Re: Re: Freeing memory in Mathematica

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

> bettina_hansen at writeme.com wrote in message <7q9g8i$o43 at smc.vnet.net>... > >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 salford-software.com Yes, the value of Out records the last non-Null result if the input was a compound expression. Dave Withoff Wolfram Research