$HistoryLength specifies the number of previous lines of input and output to keep in a Mathematica session.
The default setting for $HistoryLength is Infinity.
Values of In[n] and Out[n] corresponding to lines before those kept are explicitly cleared.
Using smaller values of $HistoryLength can save substantial amounts of memory in a Mathematica session.
See Section 2.14.1.
See also: $Line.
New in Version 3.