This is documentation for Mathematica 7, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

MemoryConstrained

MemoryConstrained[expr, b]
evaluates expr, stopping if more than b bytes of memory are requested.
MemoryConstrained[expr, b, failexpr]
returns failexpr if the memory constraint is not met.
  • MemoryConstrained generates an interrupt to stop the evaluation of expr if the amount of additional memory requested during the evaluation of expr exceeds b bytes.
Run a command until a memory limit is exceeded:
The loop ran until memory allocation for the result of Range exceeded the limit:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
Run a command until a memory limit is exceeded:
In[1]:=
Click for copyable input
Out[1]=
The loop ran until memory allocation for the result of Range exceeded the limit:
In[2]:=
Click for copyable input
Out[2]=
New in 1 | Last modified in 6