| Author |
Comment/Response |
jf
|
10/08/11 1:56pm
In Response To 'Re: Export function consumes memory' --------- Patrick was optimistic about $HistoryLength.
In[1]:= 2 + 3
Out[1]= 5
In[2]:= oldHistory = $HistoryLength
$HistoryLength = 0
$HistoryLength = oldHistory
Out[2]= \[Infinity]
Out[3]= 0
Out[4]= \[Infinity]
In[5]:= %1
Out[5]= 5
Changing $HistoryLength sets the number of Ins and Outs saved during the _rest_ of the Mathematica session.
The ancient package CleanSlate might be helpful.
In[1]:= Get["Utilities`CleanSlate`"]
In[2]:= ?CleanSlate
CleanSlate[] purges all symbols and their values in all contexts that have
been added to the context search path ($ContextPath), since the CleanSlate
package was read in. This includes user-defined symbols (in the Global`
context) as well as any packages that may have been read in. It also
removes most, but possibly not all, of the additional rules for System
symbols that these packages may have defined. It also clears the In[] and
Out[] values, and resets the $Line number, so new input begins as In[1].
CleanSlate["Context1`","Context2`"] purges only the listed contexts.
In[6]:= Get["Utilities`CleanSlate`"]
In[8]:= MemoryInUse[]
Out[8]= 18994360
In[9]:= m = RandomReal[10., {10^4, 10^4}];
In[10]:= MemoryInUse[]
Out[10]= 818999376
In[11]:= Clear[m];
In[12]:= MemoryInUse[]
Out[12]= 819001984
In[13]:= CleanSlate[]
(CleanSlate) Contexts purged: {Global`}
(CleanSlate) Approximate kernel memory recovered: 781257 Kb
Out[0]= {"Utilities`CleanSlate`", "PacletManager`", "WebServices`", \
"System`", "Global`"}
In[1]:= MemoryInUse[]
Out[1]= 18992800
Note that variables created and packages loaded BEFORE the CleanSlate package is Get'd are not affected. Data structures can be set up before the package is loaded and updated any time; after running CleanSlate[] they will retain the latest values they were given.
I don't know that the CleanSlate package is officially supported, but so many people use it Wolfram still includes it with Mathematica.
URL: , |
|