MathGroup Archive 1999

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

Search the Archive

Re: Freeing memory in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19593] Re: Freeing memory in Mathematica
  • From: bettina_hansen at writeme.com
  • Date: Sat, 4 Sep 1999 01:34:28 -0400
  • References: <7q9g8i$o43@smc.vnet.net> <7qkmbq$4rr$2@dragonfly.wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

If I understand you right, you think that Mathematica saves the result
internally. Executing the following:
In[1]:=
  MemoryInUse[]
  liste = Table[Sqrt[i], {i, 1, 20000}];
  MemoryInUse[]
  liste =.
  MemoryInUse[]

Gives the ouput:
Out[1]=
  1016716
Out[3]=
  1967964
Out[5]=
  1968696

Notice that especially Out[2] is missing. So we do a
In[6]:=
  Unprotect[Out]

This gives:
Out[6]=
  {"Out"}
Out[8]=
  1020576
Which clearly shows that the large list is saved in Out[2]. But this
does not really solve my problem. I mean if a have a large program, how
do I know what output to erase? And even if there were a method to get
the right output number, it would still be rather cumbersome to delete
all my lists in this way, instead of just making a listname=.
In fact, a NoUse=42 or just a 42 as you suggest in the end of the list
creation WOULD be easier, even though it would be 'ugly'er (in a
programming sense).

Someone told me to do a ClearAll[] on the list, but this does not work
either. Another one told me to use Share[]. This is rather effective (in
this small program), however it is still more effective to use Share[]
with the NoUse variable...!

Any suggestions for easier implementation of memory freeing?

Best regards

Bettina


In article <7qkmbq$4rr$2 at dragonfly.wolfram.com>,
  "David Bailey" <dave-bailey at freeuk.com> wrote:
> My first thought was that as printed you had missed out some
>semicolons, so
> maybe things were not
> getting executed in the right order. However, adding semicolons made
>no
> difference! My second thought was that Mathematica was caching some
> information about all those square roots (does cached info count in
>the
> MemoryInUse figure?), so I replaced Sqrt by foo - still no change. 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, even though it should know the
>answer is
> Null. This is my simplified working case:
>
> Print[MemoryInUse[]];
> list = Table[foo[i], {i, 1, 20000}];
> 42;
> Print[MemoryInUse[]];
> list =.;
> Print[MemoryInUse[]];
>
> David Bailey
> Salford Software
> db at salford-software.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


  • Prev by Date: Re: LaTeX Output
  • Next by Date: A psfonts.map to use the mathematicafonts with LaTeX
  • Previous by thread: Re: Re: Freeing memory in Mathematica
  • Next by thread: Re: Freeing memory in Mathematica