Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I'm creating large lists with Table I see the memory footprint increasing.

(* Out-> 16992.4 *)

data = Table[x, {x, 0, 10000}, {y, 10000}];    
(* Out-> 408372. *)

I would expect that when I generate the same command data = Table[...] just as above the memory would not increase but in fact it just allocates a new block of memory.

data = Table[x, {x, 0, 10000}, {y, 10000}];   
(* Out -> 799041. *)

Why is that? Even when I do:

(* Out-> 799044. *)

Is this expected behaviour or am I missing something? I can't seem to find a function that clears the memory.

I'm using Mathematica on Windows 7

share|improve this question

1 Answer 1

up vote 12 down vote accepted

Have you tried setting $HistoryLength to zero:


The memory is not freed, because the previous data is still available by Out[nn] or %nn.

Note that if you do this, using %, %%, %n etc., which some people use in example code will not work. And when a large data set is shown the "Show More" and "Show Less" buttons do not work. You can bypass both problems by setting $HistoryLength to 1 while still conserving a lot of memory.

share|improve this answer

Your Answer


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.