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.
. set memory 4000
. 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
. set memory 1g
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
set memory #. For example:
. set memory 4000, permanently
. 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.
set memory # command only applies to Stata 10 and 11. Automatic memory management is a new feature introduced in Stata 12.