Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Freeing memory in Mathematica

  • To: mathgroup at
  • Subject: [mg19593] Re: Freeing memory in Mathematica
  • From: bettina_hansen at
  • Date: Sat, 4 Sep 1999 01:34:28 -0400
  • References: <7q9g8i$> <7qkmbq$4rr$>
  • Sender: owner-wri-mathgroup at

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

Gives the ouput:

Notice that especially Out[2] is missing. So we do a

This gives:
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


In article <7qkmbq$4rr$2 at>,
  "David Bailey" <dave-bailey at> 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
> difference! My second thought was that Mathematica was caching some
> information about all those square roots (does cached info count in
> MemoryInUse figure?), so I replaced Sqrt by foo - still no change. It
> out that you can replace the assignment of NoUse by anything with a
> value - e.g. the number 42. It also seems that even when the memory in
> does not go down, if you test it afterwards it HAS gone back down - so
> guess is that Mathematica is holding on to the value as a possible
> 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

Sent via
Share what you know. Learn what you don't.

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