How much memory does your computer need to run Stata for Windows?

Title

Windows memory allocation

Author

Alan Riley, StataCorp

The amount of memory Stata needs to run efficiently is completely dependent
on the size of the datasets you need to load. You can actually make Stata
run more slowly by allocating too much memory to it.

If the total memory allocated to all programs (including the OS itself) on
your computer is greater than the total RAM you have, some of the memory
will have to be represented on disk as virtual memory. Anytime virtual
memory (the part of memory represented on disk) has to be accessed, the
computer will slow to a crawl.

Some users think if giving Stata 40 MB is good, giving Stata 60 MB or
even 80 MB must be better. This is not true. Once enough memory has been
allocated to Stata to allow it to load the current dataset, with enough
extra room for whatever temporary variables, programs, macros, etc., might
be needed during analysis, no speed improvements will be seen by giving even
more memory to Stata. In fact, you may hurt Stata’s performance by
forcing the OS to use virtual memory if you allocate too much memory to
Stata.

To understand why, think of memory as a rectangle on a hypothetical
computer. On this computer, imagine Stata is the only application
running and the OS uses 0 memory. Give this computer 32 MB of real
RAM, and allocate 40 MB to Stata:

+----------------+
| |

Let us imagine that the dataset with which you want to work is only 20 MB in
size. You might think that, because the dataset is smaller than the amount of
real RAM on the computer, you do not have to worry about virtual memory or
swapping. Not so! The dataset is stored as a smaller rectangle within the
larger one. Each observation of the dataset can be looked at as
“row” in memory. Depending on the shape of the rectangle of
data, some of the observations of the data may extend into the virtual
memory region:

+----------------+
|######## |

Anytime those observations are accessed, the OS will have to use the virtual
memory, swapping it into real RAM and slowing computation to a crawl.

Because the dataset is only 20 MB in size, we do not need to allocate 40 MB to
Stata. We could probably allocate 25 MB or even be generous and give 30 MB
to Stata. Either would avoid swapping and should provide enough room for
Stata to store temporary variables, macros, programs, etc.

+----------------+
|############# |

Rather than spending time trying to calculate the exact amount of memory
to give to Stata, it is usually easier to just experiment a little. If you
are working with 20 MB datasets, give Stata 25 MB. If you get a “no
room to ...” error message, you know you need to give Stata a little
more; try 30 MB. Do not give Stata 60 or 80 MB—this is overkill and
can only lead to possible use of virtual memory and slow performance.