Controlling Memory Usage

Use a sensible  $HistoryLength

By default ($HistoryLength=∞), and this causes Mathematica to  remember every 'In' cell and 'Out' cell during your entire session. This is  ridiculous because you would never make reference to an output from a very  long time ago as I do with  In[943]  in the next cell.

In[943]:=

Expand[%27]


To avoid eating up more and more memory you should put something like the
next line at the end of your (init.m) file.  That way $HistoryLenght will
always be set to 15 when you start Mathemmatica.

$HistoryLength = 15 ;

How to find your (Init.m) file.
Evaluating the next cell will return the directory where your (init.m)  file is located.

ToFileName[{$TopDirectory, "Configuration", "Kernel"}]

Save your notebook once in a while


Saving your notebook allows the Front End to return excess memory to the
Operating System.

Clear the Clipboard


If you Copy or Cut something that requires a lot of memory clear the
ClipBoard when you are done with it. An easy way to essentially clear the
clipboard is to select a small expression, a few words in a text cell, or
something else that is small, and select Copy under the Edit menu.

End with ; (a semi-colon) to avoid lengthy output


Ending with a semi-colon suppresses output. When an output is very long this
saves time and memory.


Created by Mathematica  (May 17, 2004)