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

$RecursionLimit

$RecursionLimit
gives the current limit on the number of levels of recursion that Mathematica can use.
  • $RecursionLimit=n sets the limit on the number of recursion levels that Mathematica can use to be n.
  • Infinity removes any limit on the number of recursion levels.
  • Each time the evaluation of a function requires the nested evaluation of the same or another function, one recursion level is used up.
  • On most computers, each level of recursion uses a certain amount of stack space. $RecursionLimit allows you to control the amount of stack space that Mathematica can use from within Mathematica. On some computer systems, your whole Mathematica session may crash if you allow it to use more stack space than the computer system allows.
  • MemoryInUse and related functions do not count stack space.
$RecursionLimit limits infinite recursion with circular definitions:
Temporarily reset $RecursionLimit:
$RecursionLimit limits infinite recursion with circular definitions:
In[1]:=
Click for copyable input
Out[1]=
 
Temporarily reset $RecursionLimit:
In[1]:=
Click for copyable input
Out[1]=
Use ReleaseHold to keep going with the recursion:
The recursion limit can be set to to allow any number of recursion steps:
The recursion limit protects against recursive runaway definitions:
The iteration limit protects against runaway definitions:
New in 1