help memory
-------------------------------------------------------------------------------
Title
[D] memory -- Memory size considerations
Syntax
Change amount of memory allocated to Stata
set memory #[b|k|m|g] [, permanently]
Report on Stata's memory usage
memory
Display memory settings
query memory
Use virtual memory more efficiently
set virtual {on|off}
Set maximum number of variables in Stata/MP and Stata/SE
set maxvar # [, permanently]
where # is specified in bytes, kilobytes, megabytes, or gigabytes (b, k,
m, and g may be typed in uppercase), with the default being k,
and where 2048 < # < 32767 in set maxvar.
Description
You can set the size of memory only if you are using Stata/MP, Stata/SE,
or Stata/IC. For Small Stata, the amount of memory used is fixed.
set memory allows you to increase or decrease the amount of memory
allocated to Stata by the operating system while Stata is running.
memory reports Stata's memory usage. memory is available on all
Stata/MP, Stata/SE, and Stata/IC, regardless of platform. query memory
for Stata/MP and Stata/SE reports more information.
query memory displays the current memory settings; see [R] query.
set virtual specifies that Stata arrange data in memory to use virtual
memory more efficiently. You do not need to set virtual on to use
virtual memory. set virtual is off by default and is available only in
Stata/MP, Stata/SE, and Stata/IC.
set maxvar allows you to set the maximum number of variables in Stata/MP
and Stata/SE; Stata/IC and Small Stata do not allow you to change the
maximum number of variables.
Option for memory
permanently specifies that, in addition to making the change right now,
the memory setting be remembered and become the default setting when
you invoke Stata.
Option for set maxvar
permanently specifies that, in addition to making the change right now,
the new limit be remembered and become the default setting when you
invoke Stata.
Examples
Resetting the amount of memory
. set memory 4m
no; data in memory would be lost
r(4);
. drop _all
. set memory 4m
. set memory 32m
. set memory 1m
. set memory 1g
. set memory 3g
op sys refuses to provide memory
r(909);
Obtaining a memory report
. memory
or
. query memory
Using virtual memory slightly more efficiently
. set virtual on
...
. set virtual off
Do not set virtual on unnecessarily, which will slow Stata down. Stata
goes to extra work to arrange its memory to be more efficient in using
virtual memory.
Saved results
memory saves the following in r():
Scalars
r(k) number of variables
r(width) width of dataset
r(N_cur) maximum observations (current partition)
r(N_curmax) maximum max. observations (current partition)
r(k_cur) maximum variables (current partition)
r(w_cur) maximum width (current partition)
r(M_data) total memory available to data (bytes)
r(size_ptr) size of memory pointer (bytes)
r(matsize) matsize
r(adosize) adosize
r(M_oh) total memory for set maxvar (fixed if Stata/IC or
Small Stata)
r(M_matsize) total memory for set matsize
r(M_dm) total memory for programs, saved results, etc.
Also see
Manual: [D] memory
Help: [D] compress, [R] matsize, [R] query