Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

While tinkering with a notebook that loads a large chunk of data in memory, I noticed that if I run it multiple times, the past chunks reside in memory. I understand that the reason (or one of) for which this happens is that the past output mechanism (%) keeps a reference to them, so they cannot be garbage collected.

Is there a way to explicitly make Mathematica forget some data?

share|improve this question
1  
You can set $HistoryLength = 0 for instance. – b.gatessucks Nov 20 '12 at 12:03
    
related mathematica.stackexchange.com/questions/9634/… – chris Nov 20 '12 at 13:17
    
Also related (or arguably duplicate) mathematica.stackexchange.com/questions/4322/… – Jacob Akkerboom Mar 17 '13 at 18:59
up vote 4 down vote accepted

Use

 $HistoryLength = k

to keep the last k lines of input and output.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.