How to Increase Memory in Stata 10 and 11 Permanently

A simple command can increase the amount of memory allocated to Stata 10 and 11 permanently.

The operating system allocates only 1 megabyte of memory to Stata 10 and 11 out of the box.

This poses a problem if you are dealing with datasets that require a larger amount of memory; Stata will tell you that there is no room and it cannot analyze the data.

To change the amount of memory allocated to Stata, type set memory #, where # is the amount of memory you want to allocate.

For example:

. set memory 4000

or

. set memory 4m

Both commands will allocate 4 megabytes (m) of memory.

If you want to allocate 1 gigabyte (g) of memory, type

. set memory 1000000

or

. set memory 1g

The set memory # command is good only for the current session. The operating system will allocate the default amount of memory when you start a new session.

To allocate memory permanently in Stata 10 and 11, add permanently or perm after set memory #. For example:

. set memory 4000, permanently

or

. set memory 4m, perm

This will tell Stata to allocate 4 megabytes of memory for the current session and any future session of Stata. Be careful not to allocate too much memory to Stata, as this means less RAM will be available for other processes in your system.

The set memory # command only applies to Stata 10 and 11. Automatic memory management is a new feature introduced in Stata 12.

Leave a Comment