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.

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

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]=
Introduced in 1988
(1.0)
| Updated in 2007
(6.0)